It should be very easy. How to find a button through its value (jQuery Selector)

I have this HTML:

<div id='grid'> <input type="button" value="edit"/> <input type='button' value='update'/> </div> 

How to connect a click event only for the Refresh button. I know that I could add an id class or specification to it, but both of them are not possible because they are in a gridview.

I tried this:

 $("input:button[@value='update']").click(function(){alert('test');}); 

but displays a warning for both buttons. I know that I have to do something stupid. Any help is greatly appreciated.

Thanks to Kobe and Sarfraz for helping me. The following is the correct answer.

 $("input[value='update']").click(function(){alert('test');}); 
+4
source share
3 answers

Try the following:

 $("input[value='update']").click(function(){alert('test');}); 
+4
source

According to the documentation for selectors , in jQuery you shouldn't have @ when accessing attributes.

+2
source

jQuery uses a CSS selector, and you should not use @ in CSS to select it.

0
source

Source: https://habr.com/ru/post/1307540/


All Articles