日常小记

js实现点击改变元素样式

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>js重温</title>
</head>
    <p id="www">1111</p>
    <button type="button" onclick="replace3()">点击3</button><!--点击改变元素样式-->
</body>
<script>
    }
     function replace3(){
         var www=document.getElementById("www");//查找元素
         www.style.color="red";//改变样式
     }
</script>

</html>

回复

This is just a placeholder img.