惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
J
Java Code Geeks
D
DataBreaches.Net
B
Blog RSS Feed
D
Docker
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
Y
Y Combinator Blog
A
About on SuperTechFans
V
V2EX
罗磊的独立博客
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
月光博客
月光博客
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
阮一峰的网络日志
阮一峰的网络日志

博客园 - sonkoto

HTML5添加的一些常用新标签 css判断ie浏览器 [jQuery] table表格 [jQuery] menu_Sliding(menu 滑动) [jQuery]animated-hover [jQuery]animate(滑块滑动) [jQuery] simple-disappear (消失的例子)——【转】 [转]jQuery formValidator【表达校验插件】 table Editor[table排序] [jQuery] jQuery Plugins by Dylan Verheul [转]jQuery源码解读---执行过程分析 [JQuery Cycle Plugin] 图片轮换 [jQuery] 漂亮的menu+样式表切换 JQuery Cycle Plugin (jQuery循环插件_图片轮换) [转]JQuery效果展示--不看后悔N辈子 [转]DOV+CSS表单:超炫的单选框与复选框效果! [转]【★】javascript 常用代码 超经典! 【转】jQuery下拉框,单选框,多选框整理 Flash:百叶窗 效果
[jQuery]图片更换
sonkoto · 2008-07-20 · via 博客园 - sonkoto

Html 代码:

<p><img id="largeImg" src="images/img1-lg.jpg" alt="Large image" /></p>
<class="thumbs">
    
<href="images/img2-lg.jpg" title="Image 2"><img src="images/img2-thumb.jpg" /></a>
    
<href="images/img3-lg.jpg" title="Image 3"><img src="images/img3-thumb.jpg" /></a>
    
<href="images/img4-lg.jpg" title="Image 4"><img src="images/img4-thumb.jpg" /></a>
    
<href="images/img5-lg.jpg" title="Image 5"><img src="images/img5-thumb.jpg" /></a>
    
<href="images/img6-lg.jpg" title="Image 6"><img src="images/img6-thumb.jpg" /></a>
</p>

jQuery:

<script type="text/javascript">
$(document).ready(
function(){

    $(
"h2").append('<em></em>')

    $(
".thumbs a").click(function(){
    
        
var largePath = $(this).attr("href");
        
var largeAlt = $(this).attr("title");
        
        $(
"#largeImg").attr({ src: largePath, alt: largeAlt });
        
        $(
"h2 em").html(" (" + largeAlt + ")"); return false;
    }
);
    
}
);
</script>

css:

<style type="text/css">
body 
{
    margin
: 20px auto;
    padding
: 0;
    width
: 580px;
    font
: 75%/120% Arial, Helvetica, sans-serif;
}

#largeImg 
{
    border
: solid 1px #ccc;
    width
: 550px;
    height
: 400px;
    padding
: 5px;
}

.thumbs img 
{
    border
: solid 1px #ccc;
    width
: 100px;
    height
: 100px;
    padding
: 4px;
}

.thumbs img:hover 
{
    border-color
: #FF9900;
}

</style>

参考网址:http://www.bbon.cn/wp-content/uploads/demo/jquery/img-replacement.html

附件:/Files/sonkoto/img-replacement.rar