Reputation: 132
So I have a code that looks something like this
$(".something").live({
mouseover:function(e){
//do stuff
},
mouseout:function(e){
//do or undo other stuff
}
});
But since this .live
method is deprecated in jQuery1.7+, I have to do a bit of revising.
To start with, it should look like:
$(document).on("mouseover",".something",function(e){
//do stuff here
});
How about the mouseout
thingy? Any quick way to merge the two or will I be forced to make separate coding for them?
Thanks.
Upvotes: 2
Views: 100
Reputation: 146350
$(document).on({
mouseover:function(e){
//do stuff
},
mouseout:function(e){
//do or undo other stuff
}
}, ".something");
Based on:
.on( events-map [, selector] [, data] )
Upvotes: 2
Reputation:
You can leave the map:
$(document).on(
{
mouseover : function(){ ... }
, mouseout : function(){ ... }
}
, '.something'
);
Upvotes: 4