javascript - jquery multiple click event in one click event -


i used below function...for each id call 1 function..i call 1 click function @ time need use single click function this..

      .append($('<a>',{'class':'list-header','id':'call1','name':'name','value':'1'}).append('1'))       .append($('<a>',{'class':'list-header','id':'call2','name':'name','value':'2}).append('2'))       ...       ...       ...       .append($('<a>',{'class':'list-header','id':'call7','name':'name','value':'7'}).append('7'))));         $('#call1').click(function(){        });       $('#call2').click(function(){        });       ...       ...       ...       $('#call7').click(function(){        }); 

i have use 7 function above..i call 1 function @ time. need in single function..

how it?

you can try

$('#call1, #call2, #call3, #call4,#call5,#call6,#call7').                                                    click(function(event){      if($(event.target).attr('id')=='call1'){         /* specific code call1*/     } else if($(event.target).attr('id')=='call2'){         /* specific code call2*/     ------ }); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -