0

I wanna to disable the mouse clicking in some div.For this I have used the die function it is not working. Please let me know how can I do it? Is it possible in jquery?

2 Answers 2

1

This is very simple. Use this code:

$("#DIV_ID").click(function(e){
   e.preventDefault();
   e.stopPropagation()
});
Sign up to request clarification or add additional context in comments.

3 Comments

There probably is no default action performed by the div .. you may want to use stopImmediatePropagation instead or even unbind whatever event is bound to it.
@ExplosionPills I am not sure about stopImmediatePropagation. Can you explain difference b/w stopImmediatePropagation and stopPropagation?
It prevents the calling of other events bound to the same element. stopPropagation only stops the calling of events bound to ancestors.
1

use stopImmediatePropagation()...

Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree.

try this

$("#yourDivId").click(function(e){
   e.preventDefault();
   e.stopImmediatePropagation();
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.