关闭/打开div [英] Switch divs off/on

查看:73
本文介绍了关闭/打开div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦div关闭,它可以开启吗?

Once a div is offed can it be onned?

第一,

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

稍后,

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

因为div不再响应点击事件而不管它们是什么 - 它们是否可以打开一次它们被关闭了?

Because the divs are no longer responding to click events in spite of onning them - can they be onned once they are turned off?

推荐答案

你必须再次用参数绑定它,告诉它们要绑定哪个事件和要绑定事件的元素

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(){
});

你创建一个函数并绑定其中的所有事件,并在你想要绑定时调用它。 / p>

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

这篇关于关闭/打开div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆