How can I pass multiple variables on a jquery function? Like so:
$(".link1",".link2").click(function(event){
}
Also tried:
$(".link1"),$(".link2").click(function(event){
}
How can I pass multiple variables on a jquery function? Like so:
$(".link1",".link2").click(function(event){
}
Also tried:
$(".link1"),$(".link2").click(function(event){
}
Multiple selectors need only be separated by a comma in your selector string.
$(".link1, .link2").click(function(event){
}
Use
$(".link1, .link2").click(function(event){
or
$(".link1").add(".link2").click(function(event){
The comma separator is defined here : Multiple selector
use .on
, and pass the extra events as an argument to that method:
$('.link1, link2').on('click',{some:'argument'},function(e)
{
console.log(e.data);//<-- object literal {some:'arguments'}
});
Read all about it here