2
I am trying to make a div element change background color when selecting the color of my input using Js. I’m not getting anybody to help me ?
<style>
.corExemplo {
width: 150px;
height: 150px;
border-radius: 50%;
margin-bottom: 30px;
float: left;
}
</style>
<script>
function trocaCor(){
var cor = getElementById("corum").value;
document.getElementById("boxum").style.backgroundColor = cor;
}
</script>
<div id="boxum" class="corExemplo">Teste</div>
<form action="#" style="clear: both;">
<label for="corum">Cor 1</label>
<input type="color" id="corum" onchange="trocaCor();">
</form>
Wow I didn’t even notice... I’ve looked at the whole code over and over again. Thank you very much!
– Victor
We’ve all been through this countless times!!!! It worked?
– Allan Andrade
Yes, as I wanted! I’m starting now in Js, not being very easy rsrsrsr
– Victor
By any chance would you mark as answered ? because I can only do it in a couple of minutes
– Victor
I could use a little help on another code ?
– Victor
Sure, send the link to the other question.
– Allan Andrade
http://answall.com/questions/149828/estou-tentando-alterar-a-borda-da-div-e-ao-mesmo-tempo-mostrar-o-valor-em-outra
– Victor