6

I've to manipulate the interaction with an element in runtime, making it invisible and "no interactible".. The rule that can accomplish the second, is "pointer-events: none"

The problem is that it doesn't recognized from JS or jQuery... why?

1
  • Which browser do you need this work work on? pointer-events are not natively supported on any version of IE Commented Mar 8, 2013 at 13:53

2 Answers 2

21

I don't think I understand the question, but (using jQuery)

$( document.body ).css( 'pointer-events', 'none' );

will work just fine for supporting browsers (ignoring any pointer event). However, if you remove / hide the element, pointer events will of course also no longer work if you hide it by

display: none
Sign up to request clarification or add additional context in comments.

4 Comments

In jQuery i've used this syntax: $("#scrittainfo").css({pointer-events:"0"}) and it didn't work.. instead using it for manimupale the "opacity", all works fine.. For what reason?
@AnnaLica "0" is no valid value for pointer-events. Set it to none instead.
It's the same thing, too using "none".. In the project i've regularly wrote "none", i've do a mistake to post it there
@Sonia .css({pointer-events:"0"}) is not valid syntax because you can't have a - in a property without quoting it, like .css({"pointer-events":"0"}) But since you probably don't want to quote every property just to make it consistent with the ones that require quoting because of dashes, you can instead use camelCased properties which jQuery considers equivalent: .css({pointerEvents:"0"}) Or you can use their alternate syntax which only uses strings: .css("pointer-events", "0")
8

You can use the css pointer-events: none; to allow events to go through. Also, like 1j01 commented, jquery will accept camelCase to get around the problem of dashes in the name:

$('.my-class').css({pointerEvents: "none"})

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.