21

I'd like to apply this filter:

-webkit-filter: blur();

dynamically via JavaScript.

I looked everywhere online, and I couldn't find almost anything.

I would like to set the property dynamically through JavaScript via the DOM.

document.getElementById("element").style

How would I go about this?

1 Answer 1

31

As simple as:

document.getElementById("element").style.webkitFilter = "blur(1px)";
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you! :) Sorry, I was stupid... It's that easy! :P I was just assuming... you know, JavaScript is never easy? :-) Nevermind... Thanks for you help ! :)
FYI: All normally-hyphenated properties are camelCasedLikeThis when accessed as a property of the style object.
Yes, I knew that! :) Sorry for the stupidity... should have known that the same rule applied... Thanks for the heads up. @Web_Designer

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.