$(document).ready(function () {
$("#newrecord tr:odd").addClass("odd");
$("#newrecord tr:not(.odd)").find("li").hide();
$("#newrecord tr:not(.odd)").hide();
$("#newrecord tr:first-child").show();
$("#newrecord tr.odd").click(function () {
$("#newrecord tr:not(.odd)").show();
$(this).next("tr").find("li").slideToggle("slow","swing");
});
});
The following first hides all the even rows and when we click on the odd row it displays the even row and the slides down the li content of each row. I need help with when I click again the li tag slides up as I want it, but it should also hide the row. that is should call hide function on the row after slide up.
The . slideToggle() method animates the height of the matched elements. This causes lower parts of the page to slide up or down, appearing to reveal or conceal the items. If the element is initially displayed, it will be hidden; if hidden, it will be shown.
The slideToggle() method toggles between slideUp() and slideDown() for the selected elements. This method checks the selected elements for visibility. slideDown() is run if an element is hidden. slideUp() is run if an element is visible - This creates a toggle effect.
The jQuery slideToggle() method toggles between the slideDown() and slideUp() methods. If the elements have been slid down, slideToggle() will slide them up. If the elements have been slid up, slideToggle() will slide them down.
$(document).ready(function () {
$("#newrecord tr:odd").addClass("odd");
$("#newrecord tr:not(.odd)").find("li").hide();
$("#newrecord tr:not(.odd)").hide();
$("#newrecord tr:first-child").show();
$("#newrecord tr.odd").click(function () {
$("#newrecord tr:not(.odd)").show();
$(this).next("tr").find("li").slideToggle("slow","swing", function(){
//What to do on toggle compelte...
});
});
});
Lwyrn is correct, adding the third parameter to the slideToggle call will do it. For more control yet you can pass a plain object with all of the options you'd like as a parameter ( eg. .slideToggle( options )). You can read more about what those options can do at : http://api.jquery.com/slideToggle/#slideToggle-options
I find it useful to pass the object when I don't want the animation to queue (if a user clicks 50 times really fast, the animation will stack and keep toggling for a while -- undesired behavior).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With