I have a <span>
element which does something on a click event.
When I disable it, using jQuery:
$("span").attr("disabled", true);
The event handler continues to be called when I click on the span element.
I am testing in Chrome 13. Any thoughts?
The disabled attribute is not global and is only allowed on form controls. What you could do is set a custom data attribute (perhaps data-disabled ) and check for that attribute when you handle the click event.
Definition and Usage The span attribute defines the number of columns a <col> or <colgroup> element should span.
<span>: The Content Span element The <span> HTML element is a generic inline container for phrasing content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang .
Attribute Values: It contains the numeric value which specifies the number of supported element should span.
Try this:
$("span").css("pointer-events", "none");
you can enabled those back by
$("span").css("pointer-events", "auto");
The disabled
attribute is not global and is only allowed on form controls. What you could do is set a custom data attribute (perhaps data-disabled
) and check for that attribute when you handle the click event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With