<!DOCTYPE?html>
<html>
<head>
????<meta?http-equiv="Content-type"?content="text/html;?charset=utf-8"?/>
????<title></title>
????<style>
????.left?div?{
????????width:?350px;
????????height:?150px;
????????padding:?5px;
????????margin:?5px;
????????border:?1px?solid?#ccc;
?????????background:?#bbffaa;
????}
????
????p?{
????????height:?50px;
????????border:?1px?solid?red;
????????margin:?30px;
????}
????.bjcolor{?background:?#fff;}
????</style>
????<script?src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
</head>
<body>
????<h2>.hover()方法</h2>
????<div?class="left">
????????<div?class="aaron1">
????????????<p>觸發(fā)hover事件</p>
????????</div>
????</div>
????<script?type="text/javascript">
????$("p").hover(
????????function()?{
????????????$(this).css("background",?'red');
????????},
????????function()?{
????????????$(this).attr("bjcolor");??//這里換成獲取樣式表里面的樣式,或換成.addClass()方法都沒反應(yīng)
????????}
????);
????</script>
</body>
</html>
—————————————————————————————————————————————————————
是不是要結(jié)合removeClass()才行?
????$('p').hover(
????????function(){
????????????$(this).addClass("add");
????????},
????????
????????function(){
?????????????$(this).removeClass("add");
????????}
????????)
- 3 回答
- 0 關(guān)注
- 1933 瀏覽
添加回答
舉報
0/150
提交
取消