/ / JQueryMobile折りたたみ可能なヘッダー - jquery、jquery-mobile、cordova

JQueryMobile折りたたみヘッダ - jquery、jquery-mobile、cordova

var dw=function(string){
document.write(string+"-Hello");
}
<h1><script>dw("Hi")</script></h1>   //Hi-Hello

これは正常に動作します。しかし、私はこのヘッダーを折畳み式の中に入れると、ちょうどこんにちはこんにちはを印刷して折り畳みを表示しません。

<div data-role="collapsible">
<h3><script>dw("Hi")</script></h3>
<p>collapsible content.</p>
</div>

折りたたみ可能なヘッダーを変更するための回避策はありますか?

回答:

回答№1は0

したがって、CollapsibleのHeader-Textを変更する場合は、CollapsibleにIDまたはクラスを指定します。

<div id="myCollapsible" data-role="collapsible">
<h3>OldTitle</h3>
<p>Content</p>
</div>

JQMはjQueryを使用するので、いくつかのjQuery-Magicを使用することができます。

<script>
$("#myCollapsible .ui-btn-text").text("My New Title");
</script>

"pageshow"または "pagecreate"で変更したい場合は、これを試すことができます:

<script>
// $("#myPageId").bind ... would be possible too
$(document).bind("pageshow", function(){
$("#myCollapsible .ui-btn-text").text("My New Title");
});
</script>

私はあなたを助けることができると思う:)