admin管理员组

文章数量:1334912

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 .

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 .

Share Improve this question edited May 24, 2015 at 18:14 Krutik Jayswal 3,1751 gold badge17 silver badges38 bronze badges asked Jan 31, 2015 at 10:43 Surya Prakash TummaSurya Prakash Tumma 2,2034 gold badges29 silver badges50 bronze badges 1
  • 5 $('#mydiv label').text('Hello Kitty') – adeneo Commented Jan 31, 2015 at 10:44
Add a ment  | 

1 Answer 1

Reset to default 8

Use:

$('#mydiv label').text('smtext');

Update: to change second label element in mydiv:

 $('#mydiv label:eq(1)').text('smtext');

本文标签: javascripthow to change label text in a div using jqueryStack Overflow