jquery給圖片添加鼠標經過時的邊框效果
更新時間:2013年11月12日 17:30:54 作者:
鼠標經過時圖片產生塌陷,實則應該將邊框控制直接加在IMG標簽上即可,下面有個不錯的示例,大家可以感受下
一哥們兒要給圖片添加鼠標經過時的邊框效果,可惜出發(fā)點錯了,直接加在了IMG外的A標簽上致使 鼠標經過時圖片產生塌陷,實則應該將邊框控制直接加在IMG標簽上即可
錯誤代碼如下:注意紅色部分設置 (出發(fā)點就錯了)
<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>
錯誤代碼如下:注意紅色部分設置 (出發(fā)點就錯了)
復制代碼 代碼如下:
<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>
相關文章
Jquery多選下拉列表插件jquery multiselect功能介紹及使用
支持點擊label實現(xiàn)checkbox組選擇,頭部選項,如全選/ 取消全選 /關閉功能,支持鍵盤選擇等等,下面與大家分享下具體使用2013-05-05JQuery Ajax通過Handler訪問外部XML數據的代碼
JQuery是一款不錯的Javascript腳本框架,相信園子里的很多朋友對它都不陌生,我們在開發(fā)Web應用程序時難免會使用到Javascript腳本,而使用一款不錯的腳本框架將會大大節(jié)省我們的開發(fā)時間, 并可以毫不費力地實現(xiàn)很多非??岬男Ч?。2010-06-06全面解析jQuery中的$(window)與$(document)的用法區(qū)別
這篇文章主要介紹了jQuery中的$(window)與$(document)的用法區(qū)別,具體內容大家可查看下文的詳細講解,感興趣的小伙伴們可以參考一下。2017-08-08jquery實現(xiàn)加載更多"轉圈圈"效果(示例代碼)
這篇文章主要介紹了jquery實現(xiàn)加載更多"轉圈圈"效果,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-11-11基于jquery實現(xiàn)的表格分頁實現(xiàn)代碼
該方法的運用是從后臺數據庫中一次性取出所有的數據,運用Jquery把一部分數據隱藏起來,事實上數據還是全部在html頁面中2011-06-06