Reputation: 2198
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
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
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