javascript - Customization of css attributes -


I am trying to customize the color attribute of this element in this way:

 < Code> & lt; H2 style = "float: left; font-family: 'open cens', non-serif, color: #fbfbfb font-size: 40px; position: relative; margin-top: -458px; margin-left: 90px ; "Class =" main title "& gt; Test & lt; / H2 & gt;   

JS code (included in the top of the html page)

  (function () {document.getElementsByClassName ('main-title') color = ' Black';}) ();   

Doing this will not change the color. It is the same problem to include in the lower part of the page. In addition, I have tried to include the CSS file, in place of the JS file ( .main-title {color: black;} ), but it is still the same. How do I fix this?

Any great ideas?

should be there

  document.getElementsByClassName ('main-title ') [0] .style.color =' black ';   

Because getElementsByClassName does not return the archive, there is no single element and is important in the property of color .

You have top-margin = -458px , so that element will never appear. Maybe you can see that element yourself.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -