leoOrion leoOrion - 2 years ago 103
jQuery Question

Making a span unclickable temporarily

In a simon game, when the series is being shown to the user, I want the span(colored quadrants) to be unclickable. Currently I am employing this function which adds the

to the span when it is being animated.

function toggleUnclickable(){
//unclickable class has the css property pointer-events:none


I am calling this function before the animation starts and after the animation ends.

function animateGeneratedPattern() {


function animateNextPattern(lightup) {
.... // code for animation


But I am still able to click when the spans are being animated?? Is there something wrong that I am doing ??

Answer Source

Try to use this in your elements to enable and disable the click:

  $( "#myElement").unbind( "click" ); //disable click
  $( "#myElement").bind( "click" ); //enable
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download