gpt4 book ai didi

javascript - 使用单独的按钮在 JQUERY Mobile 中触发可折叠

转载 作者:行者123 更新时间:2023-11-30 14:08:13 25 4
gpt4 key购买 nike

我在 JQUERY Mobile 中有一个可折叠的,我正在使用它作为阅读更多。当可折叠项展开时,有一个固定按钮,屏幕底部显示关闭以关闭可折叠项,因此您无需滚动回顶部即可关闭可折叠项。

我想要做的是使用屏幕底部的固定关闭按钮触发可折叠的关闭。我尝试过绑定(bind)方法,但我的经验不足阻碍了我的理解。

这是我使用的代码。

<div id="showbutton" data-role="collapsible" data-theme="b" data-transition="turn" data-content-theme="d" class="ui-shadow ui-btn-inline">
<h2>Read more</h2>
<h2 id="content">Lots and lots of content here</h2>

<footer align="center" id="closefooter" data-role="footer" data-position="fixed" data-theme="b">
<script>
$(function() {
$("#closebutton").click(function() {
console.log("ok");
$( "#showbutton" ).trigger( "closebutton" );
});
});
</script>
<a id="closebutton">close</a>
</footer>

</div>

最佳答案

工作示例:http://jsfiddle.net/nmxav27t/

$(document).on("click", "#closebutton", function(event) {
$("#showbutton").collapsible("collapse");
});

您需要在要用于关闭的按钮上绑定(bind)点击(或点击事件),然后在 showbutton id 上触发折叠。

关于javascript - 使用单独的按钮在 JQUERY Mobile 中触发可折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54974500/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com