我正在使用 JqueryMobile 1.3.2。我想在用户单击标题时添加一些事件。例如,弹出一个警告“你好”。我能做什么?
<div data-role="collapsible">
<h3>I'm a header</h3>
<p>I'm the collapsible content. By default I'm closed, but you can click the header to open me.</p>
</div>
最佳答案
监听两个事件而不是绑定(bind)一个click
事件。 Collapsibles 有两个特殊事件,您可以在它们触发时收听和运行代码,expand
和 collapse
。
对于 jQuery Mobile 1.4 collapsibleexpand
和 collapsiblecollapse
。
$(".selector").on("collapse", function () {
alert("Collapsed");
});
$(".selector").on("expand", function () {
alert("Expanded");
});
关于javascript - 单击 JqueryMobile 下的可折叠后,如何弹出 "Hello"的警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22030871/