close
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<style type="text/css">
li{
width: 200px;
height: 50px;
background-color: #080;
list-style: none;
margin: 10px;
text-align: center;
line-height: 50px;
font-size: 30px;
color: #fff;
}
.deepgreen{
color: #020
}
</style>
</head>
<body>
<ul>
<li data-key='one' data-value='aa'>aa</li>
<li data-key='two' data-value='bb'>bb</li>
<li data-key='three' data-value='cc'>cc</li>
<li data-key='four' data-value='dd'>dd</li>
<li data-key='five' data-value='ee'>ee</li>
</ul>
<script type="text/javascript">
$('li').on('click mouseover',function(){
$(this).text($(this).data('key'));
$(this).addClass('deepgreen');
});
$('li').on('mouseout',function(){
$(this).text($(this).data('value'));
$(this).removeClass('deepgreen');
});
</script>
</body>
</html>
全站熱搜