Reputation: 329
How to choose all the elements of INPUT with style="color: #F20808"?
<form>
<input type="text" value="1">
<input type="text" value="2" style="color: #F20808">
<input type="text" value="3" style="color: #F20808">
<input type="submit" value="submit">
</form>
$('form').submit(function(){
if($(this).find('input').css('color') != 'rgb(242, 8, 8)'){
return true;
}
return false;
});
This way works, but I dont like:
$('form').submit(function(){
if($(this).find('input:eq(1), input:eq(2)').css('color') != 'rgb(242, 8, 8)'){
return true;
}
return false;
});
Are there any other ways?
Upvotes: 0
Views: 121
Reputation: 329
$('form').submit(function(){
alert($('input[style*="color: rgb(242, 8, 8)"]').length);
return false;
});
Upvotes: 0
Reputation: 7722
Here you have a solution, it will select all the inputs with a style attribute:
$('form').submit(function(){
alert($("input[style*=color][type*=text]").length);
});
Upvotes: 0
Reputation: 18721
input[style*="color: #F20808"]
should work as CSS3 or JQuery selector.
Upvotes: 2