码迷,mamicode.com
首页 > Web开发 > 详细

jquery鼠标经过字体发生变化-图片发生变化//为注释内容

时间:2014-10-05 18:25:08      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:jquery   jquery属性   

<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>部长练习jquery的属性</title>
<script src="js/jquery-1.11.1.min.js"></script>


<style>
.bor{border:10px solid yellow;}
.red{color:red;}
</style>
<script>
$(document).ready(function(e) {
    
    //增加属性居中
    //$('div').attr('align','center');
    
    //设定多个属性
    $('div').attr({'align':'center','id':'myaa','title':'aaaaaaaaa'});
    
    //$('div').css('text-align','right');
    
    //读取align属性值,并提示框显示出来
    //alert($('div').attr('align'));
	
	//鼠标经过更换图片
    $('img:first').hover(function(){
        $(this).attr('src','b.jpg');
		
		//鼠标经过增加样式
        $(this).addClass('bor');
		
	//鼠标离开还换为原来的图片
    },function(){
        $(this).attr('src','33.jpg');
        
		//鼠标离开减去样式
		$(this).removeClass('bor');
    });
    
	//鼠标经过字体变颜色
    $('h1:first').hover(function(){
        $('h1:first').toggleClass('red');
    },function(){
        $('h1:first').toggleClass('red');
    });
    
});
</script>
</head>

<body>
<h1>鼠标经过换图片</h1>
<div>ok</div>
<img src='33.jpg' width="300" height="200">
<hr>
<img src='33.jpg' width="300">
<img src='b.jpg' width="300" height="200">

</body>
</html>

jquery鼠标经过字体发生变化-图片发生变化//为注释内容

标签:jquery   jquery属性   

原文地址:http://blog.csdn.net/buzhang1314/article/details/39803735

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!