javascript - for each element of a class, check the contents to see if it contains a string, and then update only that element if it does -
code version 1: var 1 = "one"; $.each($(".buttons"),(function() { if ($("this:contains(one)")) { $(this).addclass( "currentbutton" ); }; })); code version 2: var 1 = "one"; $(".buttons").each(function(a, e) { if ($("e:contains(one)")) { $(e).addclass( "currentbutton" ); }; }); i think see i'm trying do. problem updating specific element text matched, elements updated when 1 matches. edit: html below: <input type="submit" class="buttons" value="one"> <input type="submit" class="buttons" value="two"> <input type="submit" class="buttons" value="one & two"> i using inputs programmatically added buttons using asp.net/c# i have attempted couple of solutions , i'm s