简体   繁体   English

关闭/打开div

[英]Switch divs off/on

Once a div is offed can it be onned? 一旦div关闭,就可以启用吗?

FIRST, 第一,

        $("#num-one").off();
        $("#num-two").off();
        $("#num-three").off();

THEN LATER ON, 然后,

        $("#num-one").on();
        $("#num-two").on();
        $("#num-three").on();

Because the divs are no longer responding to click events in spite of onning them - can they be onned once they are turned off? 因为div尽管已启用,但它们不再对click事件作出响应-将它们关闭后是否可以启用on?

You have to bind it again with parameters, "telling" them which event you want to bind and what element on which you want to bind the event. 您必须再次使用参数将其绑定,“告诉”您要绑定的事件以及要绑定该事件的元素

$("#num-one").on('click', function(){
});

You an make a function and bind all events in it and call it when you want to bind. 您创建一个函数并绑定其中的所有事件,并在要绑定时调用它。

function bindMyEvents()
{

    $("#num-one").on('click', function(){
    });

    $("#num-two").on('click', function(){
    });

    $("#num-three").on('click', function(){
    });

}

bindMyEvents(); // to bind the events with single call

or 要么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM