我希望能够接触到以下 html 结构
<div id="collection_propID214_formID1">
<p class="fieldHeaderContainer">
<strong>Add by ID:</strong>
</p>
</div>
并使用 jQuery 更改标记内的文本。这可能吗?
最佳答案
您可以使用 .text()
更改 div
中 strong
标签的文本。
试试这个:
$('#collection_propID214_formID1 strong').text('Your text here');
或者
$('#collection_propID214_formID1').find('strong').text('Your text here');
P.S:如果有不止一个强元素,这将更改所有元素的文本。
关于javascript - jQuery改变嵌套在div、段落标签和强标签中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25512705/