该代码应该在<script>包含mouseover事件的标记之间使用javascript ,并且HTML页面中的列表项必须按如下方式设置样式:normal - black,12,bold和over yellow,15,bold,italic.
<html>
<head>
<title> Using mouseover eve </title>
<script language = "javascript">
<!--
function changeStyle() {
var item = document.getElementByTagName("li");
item.style.color = "yellow";
item.style.fontSize = "15pt";
item.style.fontWeight = "bold";
item.style.fontStyle = "italic";
}
-->
</script>
</head>
<body>
<ul style = "color: black; font-size: 12pt; font-weight: bold" >
<li onMouseOver = "changeStyle()"> item 1 </li>
<li onMouseOver = "changeStyle()"> item 2 </li>
</ul>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) javascript ×1