Reputation: 23
the jquery is the best way to make beautyful effects
but I want to know if is't possible to reducing this code
$(function(){
$("obj").mouseover(function(){
// do something
});
$("obj").mouseout(function(){
// ...
});
});
to some thing like
$(function(){
$("obj").mouseover(function(){
// do something
}else{
// ...
}
});
Upvotes: 2
Views: 1480
Reputation: 23250
Most jQuery functions return a reference to the Object they are attached to so you can actually do:
$("obj").mouseover(function(){
...
}).mouseout(function(){
...
});
Upvotes: 0
Reputation: 1038890
You could subscribe to the .hover
event which could take 2 callbacks:
$(function() {
$("obj").hover(function() {
// do something
}, function() {
// ...
});
});
Upvotes: 1