I want change background color
without using click button
<script>
onclick.document.getElementById('myDiv').style.backgroundColor = 'red';
</script>
I want change background color
without using click button
<script>
onclick.document.getElementById('myDiv').style.backgroundColor = 'red';
</script>
you have to attach click event and then you can do it , there is nothing like this onclick.document.getElementById(
document.addEventListener("click", function(){
document.getElementById("myDiv").style.backgroundColor = 'red';
});