方法一:(推荐)
//遍历city类 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" }); }});
方法二:
//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"; }}