开发者

disable clicking of a divs element

开发者 https://www.devze.com 2023-02-15 19:54 出处:网络
I have div that goes in to an edit mode... the div contains buttons, links++. In edit mode i want to disable all开发者_开发技巧 of these, and enable them when i exit edit mode.

I have div that goes in to an edit mode... the div contains buttons, links++. In edit mode i want to disable all开发者_开发技巧 of these, and enable them when i exit edit mode.

Ive tried

$("#container").children().disableSelection();

but it does not work :-(


Edit mode enter:

$("#container").children().bind('click', function(){ return false; });

Edit mode exit:

$("#container").children().unbind('click');


Give all elements that you want to prevent clicking a class of "noclick", then when in edit mode:

$(".noclick").click(function(e) {
    if(editMode) {
        e.preventDefault();
    }
});


you use below that will help you:

$("#container").hide();

and when exit edit mode do: $("#container").show();


css:

.dis{pointer-events:none}

Jquery:

$("#container").addClass("dis"); //disables

$("#container").removeClass("dis"); //enables

0

精彩评论

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