2

I'm trying to use the ussual method of changing a css property with javascript. The problem is that the webkit based attributes start with a dash making the javascript invalid.

document.getElementById('circle1').style.-webkit-animation = 'upDown 15s infinite';

How can I modify this code to be valid.

0

3 Answers 3

3

Refer to this question:

test.style.webkitAnimationName = 'colorchange'; // you had a trailing space here which does NOT get trimmed
test.style.webkitAnimationDuration = '4s';
Sign up to request clarification or add additional context in comments.

Comments

2
document.getElementById('circle1').style['-webkit-animation'] = 'upDown 15s infinite';

Comments

2

You can use .setAttribute():

document.getElementById('circle1').setAttribute("style", "-webkit-animation: upDown 15s infinite");

1 Comment

This will overwrite any other space-separated terms in the style attribute value.

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.