14.4 交互与更新
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="//cdn.bootcss.com/jquery/3.2.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#aLink").hover(function() { $(this).css({
"color": $(this).attr("id"),
"background-color": "green" });
});
$("#aLink").mouseout(function() {
$(this).css({
"color": "white",
"background-color": "red"
});
});
$("#aLink").click(function(event) {
$("#colorMe").attr("class",$(this).attr("id"));
event.preventDefault();
});
});
</script>
</head>
<body>
<div id="content">
123
</div>
<a id="aLink">点击链接</a>
</body>
</html>