jquery - Make the Accordion works on click event of a button -
i have accordion in page
at end of each header, have button, want accordion open content when user click on button , not on header.
my idea identify comes click, don't if best approach.
// button @ end of header $("#divatender").click(function (data) { if ($("#content1").is(":visible") == true) { $("#accordion").accordion({ active: false }); } else { $("#accordion").accordion({ active: 0 }); } }); //change event of accordion $("#accordion").on("accordionchange", function (event, ui) { // how can discover button triggered or not });
html
<div id="accordion"> <h3 class="segundopost" style="color: #ffffff !important;"> new contract <div id="divatender" style="float: right; margin-right: 10px;"> atend </div> </h3> <div id="content1" style="display: none;"> @* here *@ </div> </div>
when click on header (<h3>
) accordion shows <div id='content1'>
, should happens when click on <div id='divatender'>
try following (you need adapt needs) : http://jsfiddle.net/qyguy/2/
$("#accordion").accordion(); $("#accordion .ui-accordion-header").unbind('click'); $(".accordion_options").click(function() { var current = parseint($(this).attr("rel")); if(typeof current !== "undefined") $("#accordion").accordion({ active: current }); });
Comments
Post a Comment