比如一个div中,有很多标签,怎么通过这个div来控制这些里面的元素呢?比如鼠标放上这个div,里面所有标签的字都变成白色?可以实现吗?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题 1</title>
<style type="text/css">
.red{
color:red
}
.write{ color:blue;}
</style>
</head>
<body>
<div id="div" onmouseover="color('red')" onmouseout="color('')"><span>A</span>
<span class="write">B</span>
<span>C</span>
<span>D</span>
</div>
<script type="text/javascript">
function color(c){
document.getElementById("div").className=c
}
</script>
</body>
</html>