html 用javascript改变div元素的颜色

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 用javascript改变div元素的颜色相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html>
<head>
<script>
function mousegone() {
    document.getElementById("plush").style.color = "magenta";
}
function mouseon() {
    document.getElementById("plush").style.color = "red";
}
function myFunction() {
    var x = document.getElementById("fname");
    x.value = x.value.toUpperCase();
}
</script>
</head>
<body>

<div id="plush" onmouseover="mouseon()" onmouseout="mousegone()"><p id="bob">When you leave the input field, a function is triggered which transforms the input text to upper case.</p></div>

</body>
</html>

以上是关于html 用javascript改变div元素的颜色的主要内容,如果未能解决你的问题,请参考以下文章