P粉2860467152023-09-02 19:39:28
You cannot change the properties of an element by clicking on another element, but you can do so through JavaScript. Just add the <script>
tag at the end of your <body>
tag and onclick on the
<a> tag ()
event:
<body> <a href="#p4" onclick="changeColor()">跳转到P4</a> <p id="p4">我是P4</p> <script> function changeColor() { document.getElementById("p4").style.backgroundColor = "yellow"; } </script> </body>