I've got an input with a class name of .aa_ant that contains the value 1.
Now, when I'm loading the page I'm doing this (CASE 1):
alert($('.aa_ant[value*=1]').length )
it outputs 1 as expected.
Now, I'm changing it to (CASE 2):
alert($('.aa_ant[value*="1"]').length )
It stops working. Also, if I change the 1 to a it also stops working (both CASES 1 and 2).
What I am doing wrong?
Update: the .aa_ant is a knockout control:
<input class='aa_ant' data-bind='value: aa_ant, readOnly: is_readonly' />
Could that be a problem ?
Update: With the length property I want to see if there are any input elements that contain that value (I don't want any elements to have that value). Also, I know that I could get all .aa_ant elements and enumerate through them to see if anyone contains the value but I'd like to do it jquery-ish.
Update: Here's the actual solution for reference:
if($('.aa_ant').filter(function(index) {
if(this.value.indexOf("1") >=0) {
return true ;
}
return false ;
}).length>0 ) {
alert("Error");
}
Thanks for the help !
1to a what? - nnnnnn