标签:doc jquer log color 类方法 style else var text
方法一:(推荐)
//遍历city类
<div name = ‘city‘ class = ‘city‘></div>
var ck = $(".city"); ck.each(function () { if ($(this).text().indexOf("江门") != -1) { $(this).css({ "color": "#19b955", "font-weight": "bold" }); } else { $(this).css({ "color": "#333", "font-weight": "normal" }); } });
方法二:
<div name = ‘city‘ class = ‘city‘></div> //var ck = $(".city"); var ck = document.getElementsByName("city"); for (var k = 0; k < ck.length; k++) { if (ck[k].text.indexOf() != -1) { ck[k].style.color = "#19b955"; ck[k].style.fontWeight = "bold"; } else { ck[k].style.color = "#333"; ck[k].style.fontWeight = "normal"; } }
标签:doc jquer log color 类方法 style else var text
原文地址:http://www.cnblogs.com/tianhengblogs/p/6336522.html