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

これは正常に機能します。しかし、このヘッダーを折りたたみ可能なものの中に入れると、Hi-Helloが出力され、折りたたみ可能なものは表示されません。

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

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

4

1 に答える 1

0

したがって、折りたたみ式のヘッダーテキストを変更する場合は、折りたたみ式に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>

私があなたを助けることができることを願っています:)

于 2012-07-20T11:32:08.090 に答える