ben*_*ben 4 jquery jquery-selectors
我正在尝试将一些文本附加到跨度中的标题.但我不知道如何附加到实际的标题,而不仅仅是跨度.
样式:
h1 {font-size:250%;color:red;}
Run Code Online (Sandbox Code Playgroud)
HTML:
<span class="note">
<h1>
some text
</h1>
</span>
Run Code Online (Sandbox Code Playgroud)
我运行这个:
$('.note:first-child').append("more text");
Run Code Online (Sandbox Code Playgroud)
但是文本会在标题标记之后附加,因此没有应用标题样式.我如何附加到标题?
$('.note h1:first-child').append("more text");
Run Code Online (Sandbox Code Playgroud)
用于插入h1每个.note类的第一个
和
$('.note:first-child h1').append("more text");
Run Code Online (Sandbox Code Playgroud)
用于插入h1第一.note类文本
首先h1是第一个.note
$('.note:first-child h1:first-child').append("more text");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9102 次 |
| 最近记录: |