Skip to content Skip to sidebar Skip to footer

Toggle Button Inside Accordion Using Jquery

I want to create a toggle button inside an accordian. Here is what I was trying to do. Javascript $j('div a').live('click', function() { $j('#toggleButton').click(function () {

Solution 1:

Try this please Working Demohttp://jsfiddle.net/stXP6/orhttp://jsfiddle.net/z8Jns/

Oh and your HTML ain't valid I have rectified it a bit now using class. i.e. id defines identity of the element hence it should be unique.

Hope it fits your need :)

code

$(".test").hide();
$(".toggleButton").click(function() {
    $(this).next(".test").slideToggle("slow");
});​

HTML

<h3><ahref="#">Number 1</a></h3><div><h4> Error1:</h4><p> some contents here </p><divid="content1"><inputtype="button"value="Hide"class="toggleButton"style="float:right;"><divclass="test"><p>jhfsnv jv jsdhv jsdvb </p></div></div></div><h3><ahref="#">Number 2</a></h3><div><h4> Error2:</h4><p> some contents here </p><divid="content1"><inputtype="button"value="Hide"class="toggleButton"style="float:right;"><divclass="test"><p>jsa shsbc sjhv sf </p></div></div></div>
Here​​

Post a Comment for "Toggle Button Inside Accordion Using Jquery"