I can't change color with append div dynamically. I want change default color of div, in red.
My HTML markup is:
<div id="risultato"></div>
Javascript code:
var result= document.getElementById('risultato');
result.style.color = "red";
result.innerHTML+= <a href="www.google.com">
but google.com have blue color not red.
I also tried with css:
<style>
#risultato {
margin-left: 18px;
font-size: 17px;
text-decoration: none;
color: red;
}
</style>
But it doesn't work. How can I do this?
var result= document.getElementById('risultato');
result.style.color = "red";
result.innerHTML+= '<a style="color:green" href="www.google.com">google</a>'
both js and css are basically fine. your innerHTML statement needs some fine tuning.
<div id="risultato">some text</div>