jquery 實現下拉選擇框

來源:互聯網
上載者:User

標籤:test   point   orm   tap   mat   value   ice   auto   mil   

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,
maximum-scale=1.0,user-scalable=no">
<title></title>
<style>
body {
-webkit-tap-highlight-color: transparent
}

* {
padding: 0px;
margin: 0px;
}

.in .content .select {
background: #FFFFFF;
margin: 0px auto;
position: relative;
cursor: pointer;
}

.in .content .select p {
margin-top: 16px;
font-size: 16px;
font-family: "microsoft yahei";
color: #666666;
text-align: center
}

.in .content .select p.latest {
border-right: 1px solid #e5e5e5;
}

.in .content ul {
width: 100%;
display: block;
font-size: 16px;
background: #FFFFFF;
position: absolute;
top: 49px;
left: 0px;
max-height: 0px;
overflow: hidden;
transition: max-height .3s ease-in;
}

.in .content ul li {
margin-left: 30px;
list-style: none;
font-size: 16px;
color: #666666;
border-bottom: 1px solid #e5e5e5;
display: flex
}

.in .content ul li span {
flex: 1;
line-height: 48px;
}

.in .content ul li i {
flex: 1;
text-align: right;
padding-right: 30px;
height: 48px;
line-height: 48px;
color: #fff;
}

.in .content ul li.Selected {
color: #00a73e;
}

.in .content ul li.Selected i {
color: #00a73e;
}

.in .content ul li:hover {
color: #00a73e;
}

.in .content.open p {
color: #00a73e
}

.in .content.open ul {
max-height: 250px;
transform-origin: 50% 0;
-webkit-animation: slide-down .5s ease-in;
transition: max-height .2s ease-in;
}

.in {
height: 48px;
border-bottom: 1px solid #e5e5e5;
display: flex;
}

.in .content {
flex: 1;
background-color: #fff
}

.select1 {
border-right: 1px solid #e5e5e5
}
</style>

</head>

<body>
<div class="in">
<div class="content">
<div class="select">
<p class="select1" data-value="所有選項">Select 1 </p>
</div>
<ul>
<li data-value="Html"><span>Html</span> <i class="icon-choice">√</i></li>
<li data-value="Html5"><span>Html5</span><i class="icon-choice">√</i></li>
<li data-value="JavaScript"><span>JavaScript</span><i class="icon-choice">√</i></li>
<li data-value="Jquery"><span>Jquery</span><i class="icon-choice">√</i></li>
</ul>
</div>
<div class="content">
<div class="select">
<p data-value="所有選項">Select 2</p>
</div>
<ul>
<li data-value="Html2"><span>Html2</span> <i class="icon-choice">√</i></li>
<li data-value="Html52"><span>Html52</span><i class="icon-choice">√</i></li>
<li data-value="JavaScript2"><span>JavaScript2</span><i class="icon-choice">√</i></li>
<li data-value="Jquery2"><span>Jquery2</span><i class="icon-choice">√</i></li>
</ul>
</div>
</div>
<script src="js/jquery-1.10.1.min.js"></script>
<script>
$(function() {
$(".select p").click(function(e) {
$(this).parent().toggleClass(‘open‘);
$(this).parent().parent().siblings().removeClass(‘open‘);
$(this).parent().parent().siblings().find(".select").removeClass(‘open‘);
$(this).parent().parent().toggleClass(‘open‘);
e.stopPropagation();
});

$(".content ul li").click(function(e) {
var _this = $(this);
$(this).parent().parent().find("p").text(_this.attr(‘data-value‘));
_this.addClass("Selected").siblings().removeClass("Selected");
$(this).parent().parent().removeClass("open");
$(this).parent().parent().find(".select").removeClass("open");
e.stopPropagation();
});

$(document).on(‘click‘, function() {
$(".content").removeClass("open");
$(".content .select").removeClass("open");
})
});
</script>
</body>

</html>

jquery 實現下拉選擇框

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.