Search code examples
javascriptwebkit

How can I set -webkit-text-fill-color in vanilla javascript


On my website, I have two a links and I am using javascript to set the href attributes of them. If there is no link, then I change the color to black. However, in Safari on iPhone, to get the color to work right, I have to use -webkit-text-fill-color. So now I need to change the webkit-text-fill-color property using javascript. I tried element.style.-webkit-text-fill-color = "color" but I get the error: Uncaught SyntaxError: Unexpected token '-'. Any idea if you can change it with javascript and if so, whats the syntax? Thanks!


Solution

  • Just use element.style.webkitTextFillColor = "color"