Developer Strange
Developer Strange

Reputation: 2198

set value for text shadow property using DOM in javascript

I want to give the value for text-shadow properties one by one using DOM in javascript. text-shadow: h-shadow v-shadow blur-radius color|none|initial|inherit;

if(conf.hasOwnProperty('vshadow')) document.getElementById('p1').style.text.hshadow = 5px;
if(conf.hasOwnProperty('hshadow')) document.getElementById('p1').style.text.vshadow = 5px;
if(conf.hasOwnProperty('blurRadius')) document.getElementById('p1').style.text.blurradius = 5px;
if(conf.hasOwnProperty('shadowColor')) document.getElementById('p1').style.text.color = red;

i tried the above code.but that does not work. is there any way to do this using DOM in javascript

Upvotes: 0

Views: 95

Answers (2)

sasi
sasi

Reputation: 534

The text shadow syntax is:

text-shadow: h-shadow v-shadow blur-radius color|none|initial|inherit;

So when you want to apply particular properties, you can apply like:

text-shadow: 2px 2px 2px #ff0000;

To apply through JS:

document.getElementById('p1').style.textShadow = "2px 2px 2px #ff0000";

Hope this helps.

Upvotes: 0

Riddler
Riddler

Reputation: 576

I dont know if the DOM objects hshadow, vshadow, blurradius really do exist but the correct code should be document.getElementById('p').style.textShadow = "5px 5px 5px red"

Upvotes: 1

Related Questions