Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

jquery on method with multiple event handlers to one selector


jquery on method with multiple event handlers to one selector  using -'javascript,jquery,jquery-selectors,jquery-1.7'

Trying to figure out how to use the Jquery .on() method with a specific selector that has multiple events associated with it.  I was previously using the .live() method, but not quite sure how to accomplish the same feat with .on().  Please see my code below:

$("table.planning_grid td").live({
  mouseenter:function(){
     $(this).parent("tr").find("a.delete").show();
  },
  mouseleave:function(){
     $(this).parent("tr").find("a.delete").hide();        
  },
  click:function(){
    //do something else.
  }
});


I know I can assign the multiple events by calling:

 $("table.planning_grid td").on({
    mouseenter:function(){  //see above
    },
    mouseleave:function(){ //see above
    }
    click:function(){ //etc
    }
  });


But I believe the proper use of .on() would be like so:

   $("table.planning_grid").on('mouseenter','td',function(){});


Is there a way to accomplish this?  Or what is the best practice here?   I tried the code below, but no dice.  

$("table.planning_grid").on('td',{
   mouseenter: function(){ //event1 },
   mouseleave: function(){ //event2 },
   click: function(){  //event3 }
 });


Thanks in advance!
    

asked Sep 22, 2015 by vickeykumar66
0 votes
4 views



Related Hot Questions



Government Jobs Opening


...