Here is the thing I have 4 box and a circle (just some sample elements) the circle is position absolute and can freely move throw boxes by a trigger.
Now I need to do something on entering the circle into a box .I was wondering if there is any way to define a custom event handler something like "circleenter" instead of "mouseenter"
Here is a JSFiddle
On mouse hover of each box the circle will move to that box and change the color suppose we want to change color of all passed squares too or do something else on squares in path.
Script:
$(document).ready(function(){
var circle=$(".circle");
$(".box").mouseenter(function(){
var $this=$(this),
idx=$this.index();
width=$this.width();
var animate={left:width*idx+18};
circle.animate(animate,200,function(){
$this.css("background","#888");
});
});
});
CSS:
#box-wrapper{
position:relative;
width:400px;
height:100px;
}
.box{
width:75px;
height:75px;
border:1px solid #000;
background:#ccc;
float:left;
cursor:pointer;
}
.circle{
position:absolute;
width:36px;
height:36px;
border-radius:50%;
background:#fff800;
left:18px;
top:18px;
}
This is just an example so the question is in such a situation can we have something like $(".box").on("circleenter")
?
Thanks in advance.