金狮镖局 Design By www.egabc.com
先给大家展示效果图,需要的朋友可以下载源码哦~
查看演示 下载源码
HTML
首先要载入jquery库和滚动插件scrollable.js
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery.js">
接着构造html主体结构。
<form action="#" method="post"> <div id="wizard"> <ul id="status"> <li class="active"><strong>1.</strong>创建账户</li> <li><strong>2.</strong>填写联系信息</li> <li><strong>3.</strong>完成</li> </ul> <div class="items"> <div class="page"> -----任意html内容----- <div class="btn_nav"> <input type="button" class="next right" value="下一步»" /> </div> </div> <div class="page"> -----任意html内容----- <div class="btn_nav"> <input type="button" class="prev" style="float:left" value="«上一步" /> <input type="button" class="next right" value="下一步»" /> </div> </div> <div class="page"> -----任意html内容----- <div class="btn_nav"> <input type="button" class="prev" style="float:left" value="«上一步" /> <input type="button" class="next right" id="sub" value="确定" /> </div> </div> </div> </div> </form>以上是一个注册表单,注意在三个.page里可以填写任何你想要的html表单内容。限于篇幅本文没有列出表单具体内容。
CSS
#wizard {border:5px solid #789;font-size:12px;height:450px;margin:20px auto; width:570px;overflow:hidden;position:relative;} #wizard .items{width:20000px; clear:both; position:absolute;} #wizard .right{float:right;} #wizard #status{height:35px;background:#123;padding-left:25px !important;} #status li{float:left;color:#fff;padding:10px 30px;} #status li.active{background-color:#369;font-weight:normal;} .input{width:240px; height:18px; margin:10px auto; line-height:20px; border:1px solid #d3d3d3; padding:2px} .page{padding:20px 30px;width:500px;float:left;} .page h3{height:42px; font-size:16px; border-bottom:1px dotted #ccc; margin-bottom:20px; padding-bottom:5px} .page h3 em{font-size:12px; font-weight:500; font-style:normal} .page p{line-height:24px;} .page p label{font-size:14px; display:block;} .btn_nav{height:36px; line-height:36px; margin:20px auto;} .prev,.next{width:100px; height:32px; line-height:32px; background:url(btn_bg.gif) repeat-x bottom; border:1px solid #d3d3d3; cursor:pointer}您可以根据实际应用环境修改css,来体现不同的外观。
jQuery
毋庸置疑,和其他插件一样,直接调用方法。
$(function(){ $("#wizard").scrollable(); });就是这么简单,现在可以通过单击下一步切换步骤了,但有问题是导航的步骤标题tab样式没有同时切换,点击下一步时应该验证当前表单输入的合法性。值得庆幸的是,两个方法使得问题变得很简单了。
onSeek:function();当滚动当前page后发生的事情,本例中我们要切换tab样式。
onBeforeSeek:function();滚动之前发生的事情,本例中我们要验证表单。请看代码:
$(function(){ $("#wizard").scrollable({ onSeek: function(event,i){ //切换tab样式 $("#status li").removeClass("active").eq(i).addClass("active"); }, onBeforeSeek:function(event,i){ //验证表单 if(i==1){ var user = $("#user").val(); if(user==""){ alert("请输入用户名!"); return false; } var pass = $("#pass").val(); var pass1 = $("#pass1").val(); if(pass==""){ alert("请输入密码!"); return false; } if(pass1 != pass){ alert("两次密码不一致!"); return false; } } } }); });最后,要提交表单,获取表单的值,你可以在最后一步“确定”按钮上绑定submit()方法,通过action提交表单。本文为了演示,采用以下方法获取输入的内容:
$("#sub").click(function(){ var data = $("form").serialize(); alert(data); });
金狮镖局 Design By www.egabc.com
金狮镖局
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
金狮镖局 Design By www.egabc.com
暂无基于jquery实现一个滚动的分步注册向导-附源码的评论...
更新日志
2024年09月23日
2024年09月23日
- 华少翌.2005-华少翌【中唱艺能】【WAV+CUE】
- 群星《十二女声Ⅱ》[WAV/CUE/分轨][527MB]
- 大自然音乐系列《漫步在山裡》[WAV/CUE/分轨][502.8MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]
- 史依弘《史依弘交响乐京剧演唱专辑HQ》头版限量编号[WAV+CUE]
- 曼丽2020《女人三十风继续吹》HQCD[WAV+CUE]
- 曼丽2021《女人三十2雾之恋》HQCD[WAV+CUE]
- 隔壁老樊.2019-我曾【好听音乐】【FLAC分轨】
- 高林生.1993-牵挂你的人是我【白天鹅】【WAV+CUE】
- 洪卓立.2012-找个懂我的女孩(国专)【英皇娱乐】【WAV+CUE】
- 曼丽2022《女人三十3晚秋》HQCD[WAV+CUE]
- 曼丽2018《女人三十4冬天》HQCD[WAV+CUE]
- 柏菲-《好歌30年壹》限量开盘母带ORMCD[低速原抓WAV+CUE]
- 大自然音乐系列《水舞》[WAV/CUE/分轨][424.3MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]