javascript代码实例教程-JQ简单图片经过效果--答一伙计

发布时间:2019-02-20 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-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(){

&nbsp; $("#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>

<p 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>

</p>

</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>

<p 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>

</p>

</body>

</html>

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的javascript代码实例教程-JQ简单图片经过效果--答一伙计全部内容,希望文章能够帮你解决javascript代码实例教程-JQ简单图片经过效果--答一伙计所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。