好的,伙计们,我有这个代码
var text = $('.css .cont_code code');
text.contents().text(function() {
$(this).each(function() {
var cssC = "background , background-color , width , height , float , margin , margin-left , margin-right , margin-top , margin-bottom , contents , border , !important"
if (text === "cssC")
{
$(this).wrap('<span class="stylesC" />');
}
})
})
它抓取所有文本节点行,而不是我在var cssC =
代码中提供的文本,任何帮助将不胜感激从未使用 jQuery 抓取 textNodes 并且对如何编写实际的 javascript 知之甚少,就像getElementById
我不流利那样,也不 jQuery 真的老实说。
基本上我要做的是获取我放置在 var cssC 中的某些文本字段,然后如果发现将其包装在一个跨度中,则span class="stylesC" />
结果应该如下所示