Possible Duplicate:
Combine two selectors with one jQuery object
I have the following jquery code:
$("#try").click(function(){
...
If I click on #try, the browser executes the function. Suppose I want to add another element, #try2, that will execute the same function. How would I add an or to the above code? I’ve tried using,
$("#try" or "#try2").click(function(){
...
but it doesn’t work.
Ir you have only
tryandtry2then you should go forYou can use comma separated multiple selector within
$()But if you have more then try
This will bind click event to those element which
ids start withtry, liketryortry1ortry2etc.According to comment
How can I detect clicked element’s id
Proof