Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    55
    Thanks
    9
    Thanked 0 Times in 0 Posts

    jQuery slide issues

    Hey everyone,

    Having some issues with the jQuery slide script. So far I haven't been able to get any of their stuff to work successfully but maybe yall will see something i overlooked. Here is the link to the jQuery slideUp page. http://api.jquery.com/slideUp/

    The situation is this: I am creating a blog system of sorts for my site and I want users to be able to minimize comments to clear up space on the page. Here is my code so far. Also my code to change the image of "Show" and "Hide" works perfectly but only works once.

    Including the jquery javascript
    Code:
    <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
    div to be hidden
    Code:
    <div class="prayerD" id="descrip01"><img src="images/icons/icon_01.png" />  Posted on: Today <br /> Comment</div>
    Slide function at bottom of the page. I am passing it the name of the id of the div to be hidden and the name of the image that the user clicks on so that it swaps that image between "Show" and "Hide".
    Code:
    function slide(id, img) {
    	if ($(id+":first").is(":hidden")) {
    		$(id).show("slow");
    		img.src='images/minimize.png';
    		img.alt='Hide';
    	} else {
    		$(id).slideUp();
    		img.src='images/maximize.png';
    		img.alt='Show';
    	}
    	
    }	
    </script>
    Last edited by Serihon; 02-29-2012 at 04:57 PM. Reason: Resolved

  • #2
    New Coder
    Join Date
    Mar 2009
    Posts
    55
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Fixed it.

    javascript
    Code:
    <script>
    function slide(id, img) {
    	if ($("#"+id).is(":hidden")) {
    		$("#"+id).show("slow");
    		img.src='images/minimize.png';
    		img.alt='Hide';
    	} else {
    		$("#"+id).slideUp();
    		img.src='images/maximize.png';
    		img.alt='Show';
    	}
    	
    }	
    </script>
    Last edited by Serihon; 02-29-2012 at 04:56 PM.

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,762
    Thanks
    23
    Thanked 548 Times in 547 Posts
    I went to the page referenced and did not find the code you posted. So I'm assuming it's yours, not theirs. Everything depends on what you are passing to the function. Lets just look at the slide up = $(id).slideUp();
    For this to work you need to pass onclick="slide('#descrip01',.....
    If you pass 'descrip01' Your line in the function needs to be
    $('#'+id).slideUp();
    Last edited by sunfighter; 02-29-2012 at 05:13 PM.

  • #4
    New Coder
    Join Date
    Mar 2009
    Posts
    55
    Thanks
    9
    Thanked 0 Times in 0 Posts
    I guess I forgot to include the code I used to trigger the event.

    Code:
    <input type="image" src="images/minimize.png" alt="Hide Comment" onclick="slide('<?php echo "descrip".$idC; ?>',this);" />
    Thanks for the reply though. Also I modified the code from their first example with the boxes.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •