手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery给图片添加鼠标经过时的边框效果
jquery给图片添加鼠标经过时的边框效果
摘要:一哥们儿要给图片添加鼠标经过时的边框效果,可惜出发点错了,直接加在了IMG外的A标签上致使鼠标经过时图片产生塌陷,实则应该将边框控制直接加在...

一哥们儿要给图片添加鼠标经过时的边框效果,可惜出发点错了,直接加在了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">

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

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

【jquery给图片添加鼠标经过时的边框效果】相关文章:

javascript实现图片跟随鼠标移动效果的方法

jQuery插件expander实现图片翻转特效

js实现精美的图片跟随鼠标效果实例

JQuery勾选指定name的复选框集合并显示的方法

jquery实现点击label的同时触发文本框点击事件的方法

jQuery替换textarea中换行的方法

基于jQuery插件实现环形图标菜单旋转切换特效

Jquery实现动态切换图片的方法

jQuery实现鼠标经过图片变亮其他变暗效果

jQuery实现html表格动态添加新行的方法

精品推荐
分类导航