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>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值