1

I am trying to assign webkit styles to an element but can not get it to work. This is what I need to assign:

-webkit-box-shadow:inset 0px 0px 0px 10px #f00;
-moz-box-shadow:inset 0px 0px 0px 10px #f00;
box-shadow:inset 0px 0px 0px 10px #f00;

This is what I have tried:

document.getElementById("EL").style.webkitBoxShadowInset = '0px 0px 0px 10px #f00';
document.getElementById("EL").style.mozBoxShadowInset = '0px 0px 0px 10px #f00';
document.getElementById("EL").style.boxShadowInset = '0px 0px 0px 10px #f00';
1
  • The rules name aren't valid. Commented Oct 18, 2015 at 11:11

2 Answers 2

1
document.getElementById("EL").style.WebkitBoxShadow = 'inset 0px 0px 0px 10px #f00';
document.getElementById("EL").style.MozBoxShadow = 'inset 0px 0px 0px 10px #f00';
document.getElementById("EL").style.boxShadow = 'inset 0px 0px 0px 10px #f00';

note the capitalization of Webkit* and Moz* and the location of the word inset

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

1 Comment

I was about to expand the answer to explain what you did wrong, do you need that explanation?
1

You can optimise the result :

var el = document.getElementById("EL"),
    bS = 'inset 0px 0px 0px 10px #f00';

el.style.WebkitBoxShadow = el.style.MozBoxShadow = el.style.boxShadow = bS;

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.