I wonder how can i do div box, which whe开发者_JAVA技巧n it is clicked then something will happen to the time when we click in some other place. Notice that when we click more than one time in our box nothing special will heppen.
$('#theDiv').one('click', function(){
$('#theOtherDiv').click(function(){
alert('I was clicked!');
});
});
http://jsfiddle.net/cpc9s/
you can keep a variable to detect whether mouse is inside or in outside,
var isIn = false;
$(document).ready(function()
{
$('#yourDiv').hover(function(){
isIn =true;
}, function(){
isIn =false;
});
$("body").mouseup(function(){
if(isIn) {
//do your work
}else{
//do your work
}
});
});
精彩评论