我的页面中有Accordion
在每个标题的末尾,我有一个按钮,我希望手风琴在用户点击按钮而不是标题时打开她的内容。
我的想法是确定点击的来源,如果这是最佳方法,我不知道。
// My Button at the end of the Header
$("#divAtender").click(function (data) {
if ($("#content1").is(":visible") == true) {
$("#accordion").accordion({ active: false });
}
else {
$("#accordion").accordion({ active: 0 });
}
});
//Change event of my Accordion
$("#accordion").on("accordionchange", function (event, ui) {
// How can I discover that my button was 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;">
@* anything here *@
</div>
</div>
当我点击标题(<h3>
)时,手风琴会显示我的<div id='content1'>
,只有在点击<div id='divAtender'>
答案 0 :(得分:1)
尝试以下操作(您需要根据自己的需要进行调整):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 });
});