代码之家  ›  专栏  ›  技术社区  ›  Vucko

当div返回正常状态时,JQuery启用点击

  •  1
  • Vucko  · 技术社区  · 12 年前

    当被点击的div处于活动状态时,有没有办法禁止点击其他div?

    我正在使用 JQuery.thoggle() 作用

    JQuery(JQuery) 对于左侧的两个div:

    $(document).ready(function() {
        $('.move_box_left_up').toggle(function() {
            $(this).css({"z-index":"20"});
            $(this).animate({"height": "529px", "width": "460px"}, "slow");
            $(this).find('img').animate({"width": "460px"}, "slow");
        },function() {
            $(this).find('img').animate({"width": "220px"}, "slow");
            $(this).animate({"height": "163px", "width": "220px"}, "slow");
            setTimeout( function(){$('.move_box_left_up').css({"z-index":"10"});},500);
        })
    });
    

    JQuery(JQuery) 对于两个右侧div:

    $(document).ready(function() {
        $('.move_box_right_up').toggle(function() {
            $(this).css({"z-index":"20"});
            $(this).animate({"height": "529px", "width": "460px", "left":"-=240px"},"slow");
            $(this).find('img').animate({"width": "460px"}, "slow");
        },function() {
            $(this).find('img').animate({"width": "220px"}, "slow");
            $(this).animate({"height": "163px", "width": "220px","left":"+=240px"}, "slow");
            setTimeout( function(){$('.move_box_right_up').css({"z-index":"10"});},500);
        })
    });
    

    JSFiddle .

    1 回复  |  直到 12 年前
        1
  •  1
  •   RenegadeMatrix    12 年前

    也许有一个条件并设置一个类似焦点的属性是合适的:

    if ($('div[selected=selected]').length < 1) {
        $(this).attr("selected", "true");
    

    编辑:更新的代码

    http://jsfiddle.net/cjmwZ/1