Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set element to unclickable and then to clickable

Tags:

I want to have a div element set to not be clickable and then set it to clickable after another element is clicked.

So, when .case is clicked:

$('.case').click(function() {  
$('#patient').addClass('active').on('click');
});

But how do I set #patient to unclickable in the first instance when I have further down:

$('#patient').click(function() { 
alert('clicked');
});
like image 684
IlludiumPu36 Avatar asked Jul 04 '13 05:07

IlludiumPu36


People also ask

How do you make a CSS Unclickable?

To make a link unclickable using CSS, you can use the pointer-events property. pointer-events: none; on the link that you want to make unclickable and it will not let you click the link.


2 Answers

$('#patient').on('click', function() {
    if ( $(this).hasClass('active') ) {
        // do whatever when it's active.
    }
    return false;
});

If you just want it to not accept, you can add this to your css (pointer-events):

#patient { pointer-events: none; }
#patient.active { pointer-events: auto; }
like image 130
kalley Avatar answered Sep 25 '22 03:09

kalley


Non clickable:

$("#ElementName").css("pointer-events","none");

Clickable:

$("#ElementName").css("pointer-events","auto");
like image 30
Nalan Madheswaran Avatar answered Sep 24 '22 03:09

Nalan Madheswaran