【问题标题】:Change details of the tag inside the tag with jQuery使用 jQuery 更改标签内标签的详细信息
【发布时间】:2016-02-19 05:36:05
【问题描述】:

我希望我能清楚地解释我的问题。

<button type="button" class="" id="myId">
<p style="color: red;">hello</p>
</button>

如果我只知道这个标签在ID为"myId"&lt;button&gt;标签中使用jquery,如何更改标签&lt;p style="color: red;"&gt;hello&lt;/p&gt;的属性style

【问题讨论】:

    标签: jquery tags


    【解决方案1】:
    $('button#myId').find('p').css('color','red')
    

    $('button#myId').children().css('color','red')
    

    如果按钮内有多个元素,则必须具体说明何时使用 children()。

    【讨论】:

      猜你喜欢
      • 2017-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多