我需要通过确切的文本匹配来定位多个类。我的代码似乎有一半的工作(文本具有一个紫色的背景时复选框取消选中),但勾选复选框为目标的文本时,似乎没有任何要发生的事情......针对精确的文本匹配(jQuery)
if ($("input:checkbox:checked#checkbox-id").length > 0) {
$('#main-content-panel .entry').filter(function(index) {
return $(this).text() == "Text"; }).css
('backgroundColor', 'orange');
}
if ($("input:checkbox:not(:checked)#checkbox-id").length > 0) {
$('#main-content-panel .entry').filter(function(index) {
return $(this).text() == "Text"; }).css
('backgroundColor', 'purple');
}
的jsfiddle:http://jsfiddle.net/KKfEF/
你还没有得到一个触发事件,对复选框的变化?你想要发生什么? – mattytommo
用我想说的第一块代码,“如果复选框被选中,将背景颜色更改为橙色”。 – Chris