How to read with JavaScript [closed]

you can use id to get the element you want to style.

<!DOCTYPE html>
<html>
<body>



<p  id="myp">Click the button to change the style of the p element.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
	var color1 = Math.floor((Math.random() * 255) + 1);
    var color2 = Math.floor((Math.random() * 255) + 1);
    var color3 = Math.floor((Math.random() * 255) + 1);
    
    document.getElementById("myp").style.color = "rgb("+color1+","+color2+","+color3+")";
}
</script>

</body>
</html>

Leave a Comment