jQuery實(shí)現(xiàn)影院選座訂座效果
jQuery實(shí)現(xiàn)影院選座訂座效果,供大家參考,具體內(nèi)容如下
效果如下:


代碼如下:
<!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>時(shí)間:<span>11月14日 21:00</span></p>
<p>座位:</p>
<ul id="selected-seats"></ul>
<p>票數(shù):<span id="counter">0</span></p>
<p>總計(jì):<b>¥<span id="total">0</span></b></p>
<button class="checkout-button">確定購(gòu)買</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; /*票價(jià)*/
$(document).ready(function() {
var $cart = $('#selected-seats'),
/*座位區(qū)*/
$counter = $('#counter'),
/*票數(shù)*/
$total = $('#total'); /*總計(jì)金額*/
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() { /*點(diǎn)擊事件*/
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') { /*已選中*/
/*更新數(shù)量*/
$counter.text(sc.find('selected').length - 1);
/*更新總計(jì)*/
$total.text(recalculateTotal(sc) - price);
/*刪除已預(yù)訂座位*/
$('#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');
});
/*計(jì)算總金額*/
function recalculateTotal(sc) {
var total = 0;
sc.find('selected').each(function() {
total += price;
});
return total;
}
</body>
</html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
jQuery使用正則表達(dá)式替換dom元素標(biāo)簽用法示例
這篇文章主要介紹了jQuery使用正則表達(dá)式替換dom元素標(biāo)簽的方法,結(jié)合具體實(shí)例形式分析了jQuery正則替換的操作技巧,需要的朋友可以參考下2017-01-01
jquery Tab 選項(xiàng)卡通用函數(shù)
用類作為選擇符雖然效率低點(diǎn)但是 可以多次重用 這個(gè)性質(zhì)不錯(cuò)2010-04-04
jQuery實(shí)現(xiàn)表格行上下移動(dòng)和置頂效果
本文給大家分享的是一款由jQuery實(shí)現(xiàn)的表格行上下移動(dòng)以及置頂效果的代碼,非常的簡(jiǎn)單實(shí)用,這里給出了核心代碼,有需要的小伙伴可以參考下。2015-06-06
jQuery實(shí)現(xiàn)帶玻璃流光質(zhì)感的手風(fēng)琴特效
這篇文章主要介紹了jQuery實(shí)現(xiàn)帶玻璃流光質(zhì)感的手風(fēng)琴特效,是一款基于jQuery+CSS3實(shí)現(xiàn)手風(fēng)琴特效,希望你可以喜歡。2015-11-11
用JQuery在網(wǎng)頁(yè)中實(shí)現(xiàn)分隔條功能的代碼
在C/S系統(tǒng)中有專門(mén)的分隔條控件,很方便實(shí)現(xiàn),但在Asp.net中卻沒(méi)有。本文介紹了一種使用JQuery技術(shù)實(shí)現(xiàn)分隔條的功能2012-08-08
基于jQuery實(shí)現(xiàn)中英文切換導(dǎo)航條效果
這篇文章主要為大家詳細(xì)介紹了基于jQuery實(shí)現(xiàn)中英文切換導(dǎo)航條效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09
jQuery插件HighCharts實(shí)現(xiàn)的2D堆條狀圖效果示例【附demo源碼下載】
這篇文章主要介紹了jQuery插件HighCharts實(shí)現(xiàn)的2D堆條狀圖效果,結(jié)合完整實(shí)例形式分析了jQuery插件HighCharts繪制條狀圖的具體實(shí)現(xiàn)技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2017-03-03
基于JQuery的一句代碼實(shí)現(xiàn)表格的簡(jiǎn)單篩選
JQuery的強(qiáng)大之處,這里就不用講了。這里將用一行簡(jiǎn)單的JQuery代碼實(shí)現(xiàn)簡(jiǎn)單的表格篩選。2010-07-07
基于jQuery實(shí)現(xiàn)網(wǎng)頁(yè)進(jìn)度顯示插件
這篇文章主要介紹了基于jQuery實(shí)現(xiàn)網(wǎng)頁(yè)進(jìn)度顯示插件的實(shí)現(xiàn)方法以及源碼下載,十分的詳細(xì),并自帶2種皮膚,這里推薦給小伙伴們。2015-03-03

