开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜