Home > DeveloperSection > Forums > How to change the CSS with javascript ?
Aaron Douglas
Aaron Douglas

Total Post:20

Points:140
Posted on    August-19-2013 12:59 AM

 JavaScript JavaScript 
Ratings:


 1 Reply(s)
 833  View(s)
Rate this:
Hi!

I do not know how to access a specific CSS using javascript.

Let us say,

#menu { color: red; }

can be accessed by

document.getElementById('menu').style.color = "blue";

But I want to access

#menu li a { height: 10%; }

How do I access that using document.getElementById() ?

Thanks is advance


shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    August-19-2013 8:28 AM

Hi!
 your answer is this

The .getElementById() function is about getting an element by a unique "id" string. If you need to get elements otherwise, there are other APIs to use: .getElementsByTagName(), .getElementsByClass(), .querySelectorAll(), etc. Browser support varies, and even .getElementById() is different between IE and other browsers.


Don't want to miss updates? Please click the below button!

Follow MindStick