开发者

Check if one of two elements are clicked

开发者 https://www.devze.com 2023-02-24 02:48 出处:网络
I am checking if one button is clicked like this $j(\'#Bu开发者_如何学JAVAtton1\').click( function () {

I am checking if one button is clicked like this

$j('#Bu开发者_如何学JAVAtton1').click( function () { 

and then performing a function but now I want to perform the same function when either Button1 or Button2 is clicked.

What is the jQuery syntax for that?


you can do this:

$j('#Button1, #Button2').click( function () { 


Another option is to use a wild card selector:

$('input[id^=Button]').click( function () { 

Matches Button1, Button2, Button99, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消