<table>
<tr><td test='222'>sss</td></tr>
<tr><td test='111'>sss</td></tr>
<tr><td test='222'>sss</td></tr>
<tr><td test='111'>sss</td></tr>
</table>
$("[test]='111'").css('background-color', 'red');
LIVE:http://jsfiddle.net/MPmyc/1/使用jQuery为自己的属性
我怎么能只为测试== 111中的CSS?现在,这为所有TD添加了CSS。
http://api.jquery.com/attribute-equals-selector/ – 2012-01-17 02:17:23
如果你想创造属性,你应该真的使用'data-'属性。像'data-test =“foo”'http://ejohn.org/blog/html-5-data-attributes/ – 2012-01-17 02:19:09