如何使用jquery更改div中的标签文本
问题描述:
我在div中有一个标签。
I have a label in a div .
<div id="mydiv">
<label>text</label>
</div>
如何编写选择器来访问标签并更改文本。
how to write a selector to access the label and change the text .
答
使用:
$('#mydiv label').text('smtext');
更新:更改mydiv中的第二个标签元素:
Update: to change second label element in mydiv:
$('#mydiv label:eq(1)').text('smtext');