I have two html pages one index.html and groups.html each page as ul > li > a list
with different class names.
I have place the click events in a seperate js file as following :
// Index Page Onclick events
$('body').on('click','.menuClass',function(e) {
e.preventDefault();
var menuid = $(this).attr('id');
alert(menuid);
});
// click on groups html >> this page alert fires twice
$('body').on('click','.grpClass',function(e) {
e.preventDefault();
var menuid = $(this).attr('id');
alert(menuid);
});
the script file is loaded in both the html files the second function for groups.html fires the click event twice.
Is there any way to avoid it or any better way to achieve the same?
vlicki understand that i can use selector but eventually there will be n pages so giving me n selectors .. looking for an elegant way to achieve the same.