资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
Jquery 焦点图 用于图片展示效果代码
效果图如下所示:
演示代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>Jquery图片展示焦点图</title> <style type="text/css"> *{ margin:0px; padding:0px; list-style:none; border:0px;} body{ font-size:12px; color:white;} #imageShow{ position:relative; width:586px; height:150px; z-index:1; overflow:hidden;} #imageShow #imageSwitch{ position:absolute; right:0px; bottom:0px; padding-left:50px; z-index:2; background-color:#C08A93; filter: Alpha(opacity=70); opacity:0.7;} #imageShow #imageSwitch li{ float:left; border-left:1px solid white; width:30px; height:14px; line-height:14px; text-align:center;} </style> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%20src%3D%22http%3A%2F%2Fcode.jquery.com%2Fjquery-1.4.2.min.js%22%3E%3C%2Fscript%3E"> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%20%0D%0A%24(document).ready(function()%7B%20%0D%0A%24imageShow%3D%24('%23imageShow')%3B%20%0D%0A%24images%3D%24('%23imageSrc%20li'%2C%24imageShow)%3B%20%0D%0A%24imageSwitches%3D%24('%23imageSwitch%20li'%2C%24imageShow)%3B%20%0D%0Aif(%24images.size()%3E0)%7B%20%0D%0Ainit()%3B%20%0D%0Avar%20timer%3DsetInterval(autoSwitch%2C3000)%3B%20%0D%0A%24imageSwitches.each(function(index%2Citem)%7B%20%0D%0A%24(item).click(function()%7B%20%0D%0AclearInterval(timer)%3B%20%0D%0AsetTimeout(function()%7Btimer%3DsetInterval(autoSwitch%2C3000)%7D%2C3000)%3B%20%0D%0A%24imageSwitches.css('background-color'%2C'').eq(index).css('background-color'%2C'%23E22E51')%3B%20%0D%0Aif(index!%3D%24imageShow.data('show'))%7B%20%0D%0A%24imageShow.data('show'%2Cindex)%3B%20%0D%0A%24images.hide().eq(index).fadeIn('slow')%3B%20%0D%0A%7D%20%0D%0A%7D)%3B%20%0D%0A%7D)%3B%20%0D%0A%7D%20%0D%0Afunction%20autoSwitch()%7B%20%0D%0A%24nowIndex%3D%24imageShow.data('show')%2B1%3B%20%0D%0Aif(%24images.size()%3E%24nowIndex)%7B%20%0D%0A%24imageSwitches.css('background-color'%2C'').eq(%24nowIndex).css('background-color'%2C'%23E22E51')%3B%20%0D%0A%24imageShow.data('show'%2C%24nowIndex)%3B%20%0D%0A%24images.hide().eq(%24nowIndex).fadeIn('slow')%3B%20%0D%0A%7Delse%7B%20%0D%0Ainit()%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0Afunction%20init()%7B%20%0D%0A%24imageShow.data('show'%2C0)%3B%20%0D%0A%24images.hide().eq(0).fadeIn('slow')%3B%20%0D%0A%24imageSwitches.css('background-color'%2C'').eq(0).css('background-color'%2C'%23E22E51')%3B%20%0D%0A%7D%20%0D%0A%7D)%3B%20%0D%0A%3C%2Fscript%3E"> </head> <body> <div id="imageShow"> <ul id="imageSrc"> <li><img src="http://files.glzy8.com/demoimg/201005/o_1.gif" _ewebeditor_ta_src="http%3A%2F%2Ffiles.glzy8.com%2Fdemoimg%2F201005%2Fo_1.gif"></li> <li><img src="http://files.glzy8.com/demoimg/201005/o_2.gif" _ewebeditor_ta_src="http%3A%2F%2Ffiles.glzy8.com%2Fdemoimg%2F201005%2Fo_2.gif"></li> <li><img src="http://files.glzy8.com/demoimg/201005/o_3.gif" _ewebeditor_ta_src="http%3A%2F%2Ffiles.glzy8.com%2Fdemoimg%2F201005%2Fo_3.gif"></li> <li><img src="http://files.glzy8.com/demoimg/201005/o_4.gif" _ewebeditor_ta_src="http%3A%2F%2Ffiles.glzy8.com%2Fdemoimg%2F201005%2Fo_4.gif"></li> <li><img src="http://files.glzy8.com/demoimg/201005/o_5.gif" _ewebeditor_ta_src="http%3A%2F%2Ffiles.glzy8.com%2Fdemoimg%2F201005%2Fo_5.gif"></li> </ul> <ul id="imageSwitch"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> </div> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程