Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
挑选电影
白蛇:缘起 - $8
罗小黑战记 - $8
送我上青云 - $8
大象席地而坐 - $10
可用
选择
已选
您已选择
0
个座位,价格为 $
0
css
@import url('https://fonts.googleapis.com/css2?family=Lato&display=swap'); * { box-sizing: border-box; } body { background-color: #242333; color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; font-family: 'Lato', sans-serif; margin: 0; } .movie-container { margin: 20px 0; } .movie-container select { background-color: white; border: 0; border-radius: 5px; font-size: 14px; margin-left: 10px; padding: 5px 15px 5px 15px; -moz-appearance: none; -webkit-appearance: none; appearance: none; } .container { perspective: 1000px; margin-bottom: 30px; } .seat { background-color: #444451; height: 12px; width: 15px; margin: 3px; border-top-left-radius: 10px; border-top-right-radius: 10px; } .seat.selected { background-color: #6feaf6; } .seat.occupied { background-color: #fff; } .seat:nth-of-type(2) { margin-right: 10px; } .seat:nth-last-of-type(2) { margin-left: 10px; } .seat:not(.occupied):hover { cursor: pointer; transform: scale(1.2); } .showcase .seat:not(.occupied):hover { cursor: pointer; transform: scale(1); } .showcase { background: rgba(0, 0, 0, 0.1); padding: 5px 10px; border-radius: 5px; color: #777; list-style-type: none; display: flex; justify-content: space-between; } .showcase li { display: flex; align-items: center; justify-content: center; margin: 0 10px; } .showcase li small { margin-left: 2px; } .row { display: flex; } .screen { background-color: white; height: 70px; width: 100%; margin: 15px 0; transform: rotateX(-45deg); box-shadow: 0 3px 10px rgba(255, 255, 255, 0.7) } p.text { margin: 5px 0; } p.text span { color: #6feaf6; }
JavaScript
const container = document.querySelector('.container'); const seats = document.querySelectorAll('.row .seat:not(.occupied)'); const count = document.getElementById('count'); const total = document.getElementById('total'); const movieSelect = document.getElementById('movie'); populateUI(); let ticketPrice = +movieSelect.value; //save selected movie index and price function setMovieData(movieIndex, moviePrice){ localStorage.setItem('selectedMovieIndex', movieIndex); localStorage.setItem('selectedMoviePrice', moviePrice); } //update total and count function updateSelectedCount() { const selectedSeats = document.querySelectorAll('.row .seat.selected'); const seatsIndex = [...selectedSeats].map(seat => [...seats].indexOf(seat)); localStorage.setItem('selectedSeats', JSON.stringify(seatsIndex)); const selectedSeatsCount = selectedSeats.length; count.innerText = selectedSeatsCount; total.innerText = selectedSeatsCount * ticketPrice; } //get data from local storage & populate UI function populateUI() { const selectedSeats = JSON.parse(localStorage.getItem('selectedSeats')); if (selectedSeats !== null && selectedSeats.length > 0) { seats.forEach((seat, index) => { if (selectedSeats.indexOf(index) > -1) { seat.classList.add('selected'); } }); } const selectedMovieIndex = localStorage.getItem('selectedMovieIndex'); if (selectedMovieIndex !== null) { movieSelect.selectedIndex = selectedMovieIndex; } } //movie select event movieSelect.addEventListener('change', e => { ticketPrice = +e.target.value; setMovieData(e.target.selectedIndex, e.target.value) updateSelectedCount(); }); //seat click event container.addEventListener('click', e => { if (e.target.classList.contains('seat') && !e.target.classList.contains('occupied')) { e.target.classList.toggle('selected'); updateSelectedCount(); } }); //initial count and total set updateSelectedCount();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>js电影票选位置-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号