jquery binding click event to multiple buttons -


i have 3 buttons b1, b2, b3. how bind click on 3 buttons. var b1 = $("#b1"); var b2 = $("#b2");

$(b1,b2).bind("click", function(){}); 

jsfiddle.net/xqpaq/

you can use .add()

b1.add(b2).add(b3).click(function(){ }) 

demo: fiddle

or use multiple selector

$('#b1, #b2, #b3').click(function(){ }) 

demo: fiddle


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -