<p> <label>* Name</label> </p> <p> <label>* Last Name</label> </p> <p> <label>Mascot Name</label> </p>
是否可以使用jQuery仅将颜色更改为字符*?我尝试使用函数find(),但我重复了标签上的所有字符.
$("p > label:contains('*')").each(function () { $(this).html($(this).html().replace("*","<span class='red'>*</span>")); });
Demo.