jQuery简易时光轴实现方法示例
程序员文章站
2022-06-02 14:44:04
本文实例讲述了jquery简易时光轴实现方法。分享给大家供大家参考,具体如下:
<...
本文实例讲述了jquery简易时光轴实现方法。分享给大家供大家参考,具体如下:
<!doctype html> <html> <head> <meta charset='utf-8'> <title>timeline</title> <style> body{ margin: 0; padding: 0; background: #e8ffe8; } #head, #content, #footer{ width: 1000px; margin: 0 auto; } #head{ text-align: center; height: 100px; line-height: 100px; } #footer{ clear: both; text-align: center; height: 30px; line-height: 30px; } /*-----大标题-----*/ .bigelement{ clear: both; position: relative; } .bigtitle{ font-size: 16px; font-weight: bold; height: 70px; line-height: 70px; background: #e8ffe8; color: #635d5a; } .bigaction, .biginfo{ float: left; } .bigaction{ border-right: 3px solid #635d5a; text-align: right; width: 220px; } .bigbuttonseemore{ float: right; width: 70px; height: 70px; text-align: center; } .bigbuttonseemore > a{ text-decoration: none; display: block; color: #635d5a; outline: none; blr: expression(this.onfocus=this.blur()); } .bigbuttonseemore > a:hover{ color: #8cdbff; } .bigcontent{ clear: both; } /*-----大标题end-----*/ /*-----小标题-----*/ .smallelement{ clear: both; position: relative; height: auto; font-size: 16px; background: #e8ffe8; color: #635d5a; } .smalltitle{ text-align: right; width: 220px; } .smalltitle, .smallcontent{ float: left; } .smallcontent{ border-left: 3px solid #635d5a; } .smallinfo{ margin-top: 20px; text-indent: 40px; } /*-----小标题end-----*/ /*-----三角形-----*/ .bigtitletrifoniconr{ border-color: #e8ffe8 #e8ffe8 #e8ffe8 #635d5a; border-style: solid; border-width: 7px; width: 0; height: 0; font-size: 0; position: absolute; top: 28px; left: 223px; } .smalltitletrifoniconl{ border-color: #e8ffe8 #635d5a #e8ffe8 #e8ffe8; border-style: solid; border-width: 6px; width: 0; height: 0; font-size: 0; position: absolute; top: 23px; left: 208px; } /*模板*/ .hide{ display: none; } /*查看更多*/ .showmore{ clear: both; text-align: center; height: 70px; line-height: 70px; } .showmore:hover{ cursor: pointer; background: #ffefdb; color: #8cdbff; } </style> </head> <body> <div id='head'> <span>订单小助手:</span> <input type='text' id='txtdoccode' /> </div> <div id='content'> <div class='timeline'></div> <div class='showmore'>查看更多</div> </div> <div id='footer'>footer</div> <!-- 大标题模板 --> <div class='hide' id='bigtitletpl'> <div class='bigelement'> <div class='bigtitle'> <div class='bigaction'>{bigaction} </div> <div class='biginfo'> {biginfo}</div> <div class='bigbuttonseemore'><a href='javascript:;'>-</a></div> </div> <div class='bigtitletrifoniconr'> </div> <div class='bigcontent'></div> </div> </div> <!-- 详细信息模板 --> <div class='hide' id='bigcontenttpl'> <div class='smallelement'> <div class='smalltitle'> <div class='smalltime'><br/>{smalltime} </div> </div> <div class='smalltitletrifoniconl'> </div> <div class='smallcontent'> <div class='smallaction'><br/> {smallaction}</div> <div class='smallinfo'> {smallinfo}</div> </div> </div> </div> <script src="http://libs.baidu.com/jquery/1.8.0/jquery.js"></script> <script> var index = 0; $(function(){ hqordernodecreate();//总部下单 }) //总部下单 function hqordernodecreate(){ var bigtitledata = { bigaction: '总部下单', biginfo: '' }; createbigtitle(bigtitledata, index); } //基地生产 function baseordernodecreate(){ var bigtitledata = { bigaction: '基地生产', biginfo: '' }; createbigtitle(bigtitledata, index); } //仓库库存 function stocknodecreate(){ var bigtitledata = { bigaction: '仓库库存', biginfo: '' }; createbigtitle(bigtitledata, index); } //发货 function delnodecreate(){ var bigtitledata = { bigaction: '发货', biginfo: '' }; createbigtitle(bigtitledata, index); } //结算 function setnodecreate(){ var bigtitledata = { bigaction: '结算', biginfo: '' }; createbigtitle(bigtitledata, index); } //生成大标题,一次生成一个 function createbigtitle(bigtitledata, index){ //生成大标题 $('.timeline').append($('#bigtitletpl').html() .replace('{bigaction}', bigtitledata.bigaction) .replace('{biginfo}', bigtitledata.biginfo) ); //生成大标题下对应的内容 var bigcontentdata = [{ smalltime: '2010.10.11', smallaction: '录单 ' + index, smallinfo: '操作时间: 10:30:55' },{ smalltime: '2010.10.15', smallaction: '审核 ' + index, smallinfo: '操作时间: 10:10:55' },{ smalltime: '2010.10.15', smallaction: '分发 ' + index, smallinfo: '操作时间: 10:10:55' }]; var bigcontenttplstr = $('#bigcontenttpl').html(); var str = ''; for(var i=0; i< bigcontentdata.length; i++){ str += bigcontenttplstr.replace('{smalltime}', bigcontentdata[i].smalltime) .replace('{smallaction}', bigcontentdata[i].smallaction) .replace('{smallinfo}', bigcontentdata[i].smallinfo); } $('.bigcontent:eq(' + index + ')').html(str).hide().slidedown(500); } //查看更多, 每次点击生成一个新的节点 $('.showmore').on('click', function(){ if($(this).text() === '查看更多'){ if(index === 0){ index++; baseordernodecreate();//基地生产 } else if(index === 1){ index++; stocknodecreate();//仓库库存 } else if(index === 2){ index++; delnodecreate();//发货 } else if(index === 3){ index++; setnodecreate();//结算 $(this).text(' →_→ 没有记录了'); } } }) // + - 按钮 收缩效果 $(document).on('click', '.bigbuttonseemore', function(){ var clickobj = $(this); var bigcontentobj = clickobj.parent().next().next(); if(clickobj.text() === '+'){ bigcontentobj.slidedown(500, function(){ clickobj.html('<a href="javascript:;" rel="external nofollow" rel="external nofollow" ">-</a>');//切换图标 }); } else if(clickobj.text() === '-'){ bigcontentobj.slideup(500, function(){ clickobj.html('<a href="javascript:;" rel="external nofollow" rel="external nofollow" ">+</a>'); }); } }) </script> </body> </html>
更多关于jquery相关内容感兴趣的读者可查看本站专题:《jquery扩展技巧总结》、《jquery常用插件及用法总结》、《jquery拖拽特效与技巧总结》、《jquery表格(table)操作技巧汇总》、《jquery中ajax用法总结》、《jquery常见经典特效汇总》、《jquery动画与特效用法总结》及《jquery选择器用法总结》
希望本文所述对大家jquery程序设计有所帮助。
下一篇: JS正则表达式判断有效数实例代码