JQ简单图片经过效果--答一伙计

一哥们儿要给图片添加鼠标经过时的边框效果,可惜出发点错了,直接加在了IMG外的A标签上致使 鼠标经过时图片产生塌陷,实则应该将边框控制直接加在IMG标签上即可
错误代码如下:注意红色部分设置 (出发点就错了)
<html>
<head>
<script type="text/javascript" src="http://www.w3school.com.cn/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#box a").mouseover(function(){
    $(this).css("border","1px solid red");
  });
  $("#box a").mouseout(function(){
    $(this).css("border","none");
  });
});
</script>
<style>
#box a{ display:block; z-index:1000; width:98px; height:98px;}
</style>
</head>
<body>
<div id="box" style="width:100px; height:100px;">
<a href="#"><img src="erwm.png" border="0" width="99" height="99"/></a>
<a href="#"><img src="erwm.png" border="0" width="99" height="99"/></a>
</div>
</body>
</html>
修改后的正确设计思路:红色部分为调整后的设置
<html>
<head>
<script type="text/javascript" src="http://www.w3school.com.cn/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#box img").mouseover(function(){
    $(this).css("border","1px solid red");
  });
  $("#box img").mouseout(function(){
    $(this).css("border","none");
  });
});
</script>
<style>
#box a{ display:block; z-index:1000; width:98px; height:98px;}
</style>
</head>
<body>
<div id="box" style="width:100px; height:100px;">
<a href="#"><img src="erwm.png" border="0" width="99" height="99"/></a>
<a href="#"><img src="erwm.png" border="0" width="99" height="99"/></a>
</div>
</body>
</html>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值