是否可以使用 jQuery 在具有相同类的每个节点末尾附加不同的单词?
例如:
<p class="xyz">Some text</p>
<p class="xyz">Some another text</p>
<p class="xyz">Text somewhere</p>
那么将是:
<p class="xyz">Some text word1</p>
<p class="xyz">Some another text word2</p>
<p class="xyz">Text somewhere word3</p>
谢谢
最佳答案
用途:
$('.xyz').each(function(i){
$(this).html($(this).html()+" word"+(i+1));//or $(this).text($(this).text()+" word"+(i+1));
});
<强> Working Demo
关于javascript - 用不同的文本更改类里面的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25668637/