日期:2014-05-16 浏览次数:20345 次
<ul>
<li><div>//</div></li>
<li><div>//</div></li>
</ul>
$("li").each(function () {
$(this).on('mouseover', function () { $('div').addClass('c-hover'); })
.on('mouseout', function () { $('div').removeClass('c-hover'); });
});
$("li").each(function () {
$(this).on('mouseover', function () { $(this).find('div').addClass('c-hover'); })
.on('mouseout', function () { $(this).find('div').removeClass('c-hover'); });
});
<!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" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<title>无标题文档</title>
<style type="text/css">
.c-hover{border:1px solid #f00}
</style>
</head>
<body>
<ul>
<li><div>//</div></li>
<li><div>//</div></li>
</ul>
<script type="text/javascript">