javascript - jQuery change text nested in div, paragraph tag and strong tag - Stack Overflow

I'd like to be able to reach out into the following html structure<div id="collection_prop

I'd like to be able to reach out into the following html structure

 <div id="collection_propID214_formID1">
   <p class="fieldHeaderContainer">
       <strong>Add by ID:</strong>
   </p>
 </div>

And change the text inside of tag, using jQuery. Is this possible?

I'd like to be able to reach out into the following html structure

 <div id="collection_propID214_formID1">
   <p class="fieldHeaderContainer">
       <strong>Add by ID:</strong>
   </p>
 </div>

And change the text inside of tag, using jQuery. Is this possible?

Share Improve this question edited Aug 28, 2014 at 19:03 imbondbaby 6,4113 gold badges22 silver badges54 bronze badges asked Aug 26, 2014 at 18:25 user2917629user2917629 9424 gold badges17 silver badges34 bronze badges 1
  • $('#collection_propID214_formID1 strong').text('Hello Wolrd!');? – Karl-André Gagnon Commented Aug 26, 2014 at 18:27
Add a ment  | 

1 Answer 1

Reset to default 6

You could change the text of the strong tags inside the div using .text().

Try this:

$('#collection_propID214_formID1 strong').text('Your text here');

JSFiddle Demo

Or

$('#collection_propID214_formID1').find('strong').text('Your text here');

P.S: If there are more than one strong elements, this would change the text for all.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744312111a4567999.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信