Jason94
Jason94

Reputation: 13620

disable clicking of a divs element

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 :-(

Upvotes: 9

Views: 37513

Answers (4)

csandreas1
csandreas1

Reputation: 2388

css:

.dis{pointer-events:none}

Jquery:

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

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

Upvotes: 0

Greg
Greg

Reputation: 21919

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

Upvotes: 2

Hitesh Prajapati
Hitesh Prajapati

Reputation: 2852

you use below that will help you:

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

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

Upvotes: 0

Furicane
Furicane

Reputation: 1183

Edit mode enter:

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

Edit mode exit:

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

Upvotes: 21

Related Questions