使用jQuery 1.4.2和许多以前的版本,可以选择这样的输入:
$('input[value=test]')
但是,在1.4.3及更高版本的情况下,此选择器不工作=(
在jQuery的较新版本中有没有办法通过价值进行选择?
解决方法
$(‘input [value =“test”]’)应该工作正常…
编辑
你可以尝试使用if语句,例如:
$("input").keyup(function(e) {
if (this.value == 'foo'){
$(this).css('backgroundColor','red');
}
else if (this.value == 'bar'){
$(this).css('backgroundColor','green');
}
else $(this).css('backgroundColor','white');
});
http://jsfiddle.net/ajthomascouk/HrXVS/