Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I modify this jQuery :submit selector example?

Looking at this jQuery example, how can I modify the code so that it only changes the color of the cell if the value of the submit button in that cell is a certain value.

i.e.-

          var submitEl = $("td :submit")

          //Only do the below if the submit buttons value is "XYZ"

          .parent('td')
          .css({background:"yellow", border:"3px red solid"})
like image 290
T.T.T. Avatar asked Mar 14 '26 08:03

T.T.T.


2 Answers

$("td input[value='SomeValue']:submit")
like image 182
Darin Dimitrov Avatar answered Mar 16 '26 21:03

Darin Dimitrov


var submitEl = $('td :submit').filter(function() { return $(this).val() == "certain"; });

You can check for the value in the selector, but it may lead to quoting headaches (depending on the value) and also it may not be quite as fast (though that's rarely a serious concern).

like image 39
Pointy Avatar answered Mar 16 '26 21:03

Pointy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!