3

In my javascript code, i am trying to access a child's class which is present in external style sheet. Using

window.getComputedStyle("className", null).getPropertyValue("color") 

throws an Unhandled error: WRONG_ARGUMENTS_ERR. Do anyone see any issue in this? I want to access the class property, which is present in external stylesheet.

Thanks

1 Answer 1

2

i think you'll need to feed getComputedStyle() a DOM-Element, not just the ClassName

maybe try:

var el = document.getElementsByClassName("className")[0];

window.getComputedStyle(el, null).getPropertyValue("color");
Sign up to request clarification or add additional context in comments.

1 Comment

@Max...I am trying the way you suggested, I think window.getElementsByClassName is returing false, as the execution does not enter the if(window.getElementsByClassName). I am using it on Opera browser. Any guesses for the workaround

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.