jQuery 移动 - 点击数据崩溃
jQuery Mobile - click data-collapsed
我有 div
和 role="collapsible"
,当用户单击下载按钮时我试图扩展它但它不起作用,这是代码:
<script>
$(document).ready(function(){
$('#download').click(function () {
console.log("ok"); // this executes
$("#set1").trigger("expand"); // but this doesn't
//document.getElementById("set1").setAttribute("data-collapsed", "false"); also tried this but no luck.
});
});
</script>
<p data-theme="a"><a id="download" href="#" class="ui-btn">DOWNLOAD</a></p>
<div data-role="collapsible" id="set1" data-collapsed="true">
<h3>INSTRUCTIONS</h3>
<p><b> Before install ...</b></p>
<p>-- text....</p>
<p>-- text...</p>
</div>
我在这里错过了什么?
在可折叠小部件上使用expand method:
$("#set1").collapsible( "expand" );
此外,您应该使用 jQM pagecreate 事件而不是 $(document).ready(...,
$(document).on("pagecreate", "#pageid", function(){...
我有 div
和 role="collapsible"
,当用户单击下载按钮时我试图扩展它但它不起作用,这是代码:
<script>
$(document).ready(function(){
$('#download').click(function () {
console.log("ok"); // this executes
$("#set1").trigger("expand"); // but this doesn't
//document.getElementById("set1").setAttribute("data-collapsed", "false"); also tried this but no luck.
});
});
</script>
<p data-theme="a"><a id="download" href="#" class="ui-btn">DOWNLOAD</a></p>
<div data-role="collapsible" id="set1" data-collapsed="true">
<h3>INSTRUCTIONS</h3>
<p><b> Before install ...</b></p>
<p>-- text....</p>
<p>-- text...</p>
</div>
我在这里错过了什么?
在可折叠小部件上使用expand method:
$("#set1").collapsible( "expand" );
此外,您应该使用 jQM pagecreate 事件而不是 $(document).ready(...,
$(document).on("pagecreate", "#pageid", function(){...