开发者

Special box -activated when clicked, deactivated when clicked another places

开发者 https://www.devze.com 2023-04-06 19:22 出处:网络
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

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
          }
        });
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消