假设我有一个段落定义为
<p>Here is a short paragraph of text which has repeating words. Words such <br>
as these will have a span around them which changes a property of words in a <br>
paragraph.
</p>
使用包含我想要应用此类的单词数组的脚本。
var blueWords = ["paragraph", "words", "which", "a"];
如何遍历段落中的每个项目并附加一个
<span color="blue"></span>
围绕 blueWords 数组中的那些预定义单词?这在 jQuery 中可能很容易完成,但我不确定如何去做。