【问题标题】:button style is messed up after changing the text through jquery通过jquery更改文本后按钮样式混乱
【发布时间】:2012-10-12 20:58:17
【问题描述】:

所以我有一个按钮,我想更新它的文本,以便其中一个字符是红色的。我实现的方式是将html设置为按钮。

<div data-role="page" id="homepage">
   <div data-role="content">
    <a id='mybutton' href="#" data-role="button" data-icon="check">My Button</a>
   </div>    
</div>

​这里是我如何通过 jQuery 更新它

.redtext{color:red;font-size:medium;text-shadow: aqua;}​

$("#mybutton").html("My Button(<span class='redtext'>0</span>)");​

0 确实是红色的,但按钮的形状现在已经变形并且样式似乎被移除了。请在此处查看演示 http://jsfiddle.net/tqeF9/

提前致谢。

【问题讨论】:

    标签: jquery jquery-ui jquery-mobile


    【解决方案1】:

    .ui-btn-text 添加到您的选择器。

    例如$("#mybutton .ui-btn-text").html("My Button(&lt;span class='redtext'&gt;0&lt;/span&gt;)");​

    原因见this post

    【讨论】:

      猜你喜欢
      • 2016-09-11
      • 1970-01-01
      • 2019-01-26
      • 1970-01-01
      • 2015-02-10
      • 1970-01-01
      • 2014-04-02
      • 1970-01-01
      • 2012-05-24
      相关资源
      最近更新 更多