jQuery实现影院选座订座效果
更新时间:2021年4月12日 20:00 点击:2061
jQuery实现影院选座订座效果,供大家参考,具体内容如下
效果如下:
代码如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width; initial-scale=1.0"> <title>jQuery影院选座订座效果代码</title> <meta name="keywords" content="jQuery,选座"> <style type="text/css"> .demo { width: 700px; margin: 40px auto 0 auto; min-height: 450px; } @media screen and (max-width: 360px) { .demo { width: 340px } } .front { width: 300px; margin: 5px 32px 45px 32px; background-color: #f0f0f0; color: #666; text-align: center; padding: 3px; border-radius: 5px; } .booking-details { float: right; position: relative; width: 200px; height: 450px; } .booking-details h3 { margin: 5px 5px 0 0; font-size: 16px; } .booking-details p { line-height: 26px; font-size: 16px; color: #999 } .booking-details p span { color: #666 } div.seatCharts-cell { color: #182C4E; height: 25px; width: 25px; line-height: 25px; margin: 3px; float: left; text-align: center; outline: none; font-size: 13px; } div.seatCharts-seat { color: #fff; cursor: pointer; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } div.seatCharts-row { height: 35px; } div.seatCharts-seat.available { background-color: #B9DEA0; } div.seatCharts-seat.focused { background-color: #76B474; border: none; } div.seatCharts-seat.selected { background-color: #E6CAC4; } div.seatCharts-seat.unavailable { background-color: #472B34; cursor: not-allowed; } div.seatCharts-container { border-right: 1px dotted #adadad; width: 400px; padding: 20px; float: left; } div.seatCharts-legend { padding-left: 0px; position: absolute; bottom: 16px; } ul.seatCharts-legendList { padding-left: 0px; } .seatCharts-legendItem { float: left; width: 90px; margin-top: 10px; line-height: 2; } span.seatCharts-legendDescription { margin-left: 5px; line-height: 30px; } .checkout-button { display: block; width: 80px; height: 24px; line-height: 20px; margin: 10px auto; border: 1px solid #999; font-size: 14px; cursor: pointer } #selected-seats { max-height: 150px; overflow-y: auto; overflow-x: none; width: 200px; } #selected-seats li { float: left; width: 72px; height: 26px; line-height: 26px; border: 1px solid #d3d3d3; background: #f7f7f7; margin: 6px; font-size: 14px; font-weight: bold; text-align: center } </style> </head> <body> <div id="main"> <div class="demo"> <div id="seat-map"> <div class="front">屏幕</div> </div> <div class="booking-details"> <p>影片:<span>星际穿越</span></p> <p>时间:<span>11月14日 21:00</span></p> <p>座位:</p> <ul id="selected-seats"></ul> <p>票数:<span id="counter">0</span></p> <p>总计:<b>¥<span id="total">0</span></b></p> <button class="checkout-button">确定购买</button> <div id="legend"></div> </div> <div style="clear:both"></div> </div> <br /> </div> <script type="text/javascript" src="http://code.jquery.com/jquery-1.12.1.min.js"></script> <script type="text/javascript" src="jquery.seat-charts.min.js"></script> <script type="text/javascript"> var price = 70; /*票价*/ $(document).ready(function() { var $cart = $('#selected-seats'), /*座位区*/ $counter = $('#counter'), /*票数*/ $total = $('#total'); /*总计金额*/ var sc = $('#seat-map').seatCharts({ map: [ /*座位图*/ 'aaaaaaaaaa', 'aaaaaaaaaa', '__________', 'aaaaaaaa__', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aa__aa__aa' ], naming: { top: false, getLabel: function(character, row, column) { return column; } }, legend: { /*定义图例*/ node: $('#legend'), items: [ ['a', 'available', '可选座'], ['a', 'unavailable', '已售出'] ] }, click: function() { /*点击事件*/ if (this.status() == 'available') { /*可选座*/ $('<li>' + (this.settings.row + 1) + '排' + this.settings.label + '座</li>') .attr('id', 'cart-item-' + this.settings.id) .data('seatId', this.settings.id) .appendTo($cart); $counter.text(sc.find('selected').length + 1); $total.text(recalculateTotal(sc) + price); return 'selected'; } else if (this.status() == 'selected') { /*已选中*/ /*更新数量*/ $counter.text(sc.find('selected').length - 1); /*更新总计*/ $total.text(recalculateTotal(sc) - price); /*删除已预订座位*/ $('#cart-item-' + this.settings.id).remove(); /*可选座*/ return 'available'; } else if (this.status() == 'unavailable') { /*已售出*/ return 'unavailable'; } else { return this.style(); } } }); /*已售出的座位*/ sc.get(['1_2', '4_4', '4_5', '6_6', '6_7', '8_5', '8_6', '8_7', '8_8', '10_1', '10_2']).status('unavailable'); }); /*计算总金额*/ function recalculateTotal(sc) { var total = 0; sc.find('selected').each(function() { total += price; }); return total; } </body> </html>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持猪先飞。
相关文章
- 这篇文章主要介绍了jquery实现加载更多"转圈圈"效果,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-11-10
- 最近接了一个项目,其中有需求要用到jquery分页控件,上网也找到了需要分页控件,各种写法各种用法,都是很复杂,最终决定自己动手写一个jquery分页控件,全当是练练手了。写的不好,还请见谅,本分页控件在chrome测试过,其他的兼容性...2015-10-30
- 有时我们在页面上需要选择数值范围,如购物时选取价格区间,购买主机时自主选取CPU,内存大小配置等,使用直观的滑块条直接选取想要的数值大小即可,无需手动输入数值,操作简单又方便。HTML首先载入jQuery库文件以及jRange相关...2015-03-15
- 本文实例讲述了jQuery实现非常实用漂亮的select下拉菜单选择效果。分享给大家供大家参考,具体如下:先来看如下运行效果截图:在线演示地址如下:http://demo.jb51.net/js/2015/js-select-chose-style-menu-codes/具体代码如...2015-11-08
- 本文实例讲述了jquery实现的伪分页效果代码。分享给大家供大家参考,具体如下:这里介绍的jquery伪分页效果,在火狐下表现完美,IE全系列下有些问题,引入了jQuery1.7.2插件,代码里有丰富的注释,相信对学习jQuery有不小的帮助,期...2015-10-30
- JQuery使我们在开发Ajax应用程序的时候提高了效率,减少了许多兼容性问题,我们在Ajax项目中,遇到ajax异步获取数据出错怎么办,我们可以通过捕捉error事件来获取出错的信息。在没给大家介绍正文之前先给分享Jquery中AJAX参...2015-11-24
- 拜读一个开源框架,最想学到的就是设计的思想和实现的技巧。废话不多说,jquery这么多年了分析都写烂了,老早以前就拜读过,不过这几年都是做移动端,一直御用zepto, 最近抽出点时间把jquery又给扫一遍我也不会照本宣科的翻译...2014-05-31
- 当页面打开时我们需要执行一些操作,这个时候如果我们选择使用jquery的话,需要重写他的3中方法,自我感觉没什么区 别,看个人喜好了,第二种感觉比较简单明了: 第一种: 复制代码 代码如下: <script type="text/javas...2014-06-07
jquery中常用的SET和GET$(”#msg”).html循环介绍
复制代码 代码如下: $(”#msg”).html(); //返回id为msg的元素节点的html内容。 $(”#msg”).html(”new content“); //将“new content” 作为html串写入id为msg的元素节点内容中,页面显示粗体的new content $(”...2013-10-13- jquery中jquery.offset().top / left用于获取div距离窗口的距离,jquery.position().top / left 用于获取距离父级div的距离(必须是绝对定位的div)。 (1)先介绍jquery.offset().top / left css: 复制代码 代码如下: *{ mar...2013-10-13
jQuery Mobile开发中日期插件Mobiscroll使用说明
这篇文章主要介绍了jQuery Mobile开发中日期插件Mobiscroll使用说明,需要的朋友可以参考下...2016-03-03- 直接为大家介绍制作过程,希望大家可以喜欢。HTML结构该页面切换特效的HTML结构使用一个<main>元素来作为页面的包裹元素,div.cd-cover-layer用于制作页面切换时的遮罩层,div.cd-loading-bar是进行ajax加载时的loading进...2015-10-30
jQuery 1.9使用$.support替代$.browser的使用方法
jQuery 从 1.9 版开始,移除了 $.browser 和 $.browser.version , 取而代之的是 $.support 。 在更新的 2.0 版本中,将不再支持 IE 6/7/8。 以后,如果用户需要支持 IE 6/7/8,只能使用 jQuery 1.9。 如果要全面支持 IE,并混合...2014-05-31- 这篇文章主要为大家详细介绍了jQuery实现广告显示和隐藏动画,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-07-05
- 本文实例讲述了jQuery实现鼠标滑过链接控制图片的滑动展开与隐藏效果。分享给大家供大家参考,具体如下:这里演示jQuery实现鼠标移动到链接上,滑动展开/隐藏图片效果,鼠标放在“上一页”“下一页”上,立即浮现出所对应的图...2015-10-30
jQuery+PHP发布的内容进行无刷新分页(Fckeditor)
这篇文章将使用jQuery,并结合PHP,将Fckeditor发布的内容进行分页,并且实现无刷新切换页面。 本文假设你是WEB开发人员,掌握了jQuery和PHP相关知识,并且熟知Fckeditor的配置和使用。...2015-10-23- jQuery实现带玻璃流光质感的手风琴特效是一款基于jQuery+CSS3实现的带玻璃流光质感的手风琴特效,分享给大家,具体如下效果图:具体代码如下:html代码: <section class="strips"> <article class="strips__strip"> <di...2015-11-24
- 有时候我们为了省事就操作键盘组合键去代替使用鼠标,我们今天就使用JQuery实现Ctrl+Enter提交表单。我们发帖时,在内容输入框中输入完内容后,可以点击“提交”按钮来发表内容。可是,如果你够“懒”,你可以不用动鼠标,只需按...2015-10-23
jQuery+slidereveal实现的面板滑动侧边展出效果
我们借助一款jQuery插件:slidereveal.js,可以使用它控制面板左右侧滑出与隐藏等效果,项目地址:https://github.com/nnattawat/slideReveal。如何使用首先在页面中加载jquery库文件和slidereveal.js插件。复制代码 代码如...2015-03-15- jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求。该插件捆绑了一套有用的验证方法,包括 URL 和电子邮件验证,同时提供了一个用来编写用户自...2015-10-30