0

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?

Algorithm
  • 329
  • 6
  • 16

3 Answers3

2
input[style*="color: #F20808"]

should work as CSS3 or JQuery selector.

MatTheCat
  • 18,071
  • 6
  • 54
  • 69
0

Working demo

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);

});
netadictos
  • 7,602
  • 2
  • 42
  • 69
0
$('form').submit(function(){
        alert($('input[style*="color: rgb(242, 8, 8)"]').length);
       return false;    
    });
Algorithm
  • 329
  • 6
  • 16