更改按钮文本jquery mobile [英] Change button text jquery mobile
本文介绍了更改按钮文本jquery mobile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用新的jquery mobile 1.0 alpha 1版本来构建移动应用程序,我需要能够切换按钮的文本。
I'm using the new jquery mobile 1.0 alpha 1 release to build a mobile app and I need to be able to toggle the text of a button. Toggling the text works fine, but as soon as you perform the text replacement the css formatting gets broken.
打乱格式化的屏幕截图:http://awesomescreenshot.com/03e2r50d2
Screenshot of the messed up formatting: http://awesomescreenshot.com/03e2r50d2
<div class="ui-bar">
<a data-role="button" href="#" onclick="Podcast.play(); return false" id="play">Play</a>
<a data-role="button" href="#" onclick="Podcast.download(); return false" id="download">Download</a>
<a data-role="button" href="#" onclick="Podcast.consumed(); return false" id="consumed">Mark Old</a>
</div>
$("#consumed").text("Mark New");
推荐答案
创建按钮时会添加一些额外的元素,一些内部< span>
元素如下所示:
When you create the button it adds some additional elements, some inner <span>
elements that look like this:
<a data-role="button" href="#" onclick="Podcast.consumed(); return false" id="consumed">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">Mark Old</span>
</span>
</a>
要更改文本,您需要此选择器:
To change the text, you'll want this selector:
$("#consumed .ui-btn-text").text("Mark New");
这篇关于更改按钮文本jquery mobile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文