jquery Simulation Select Drop-down Box value effect _jquery

Source: Internet
Author: User
The jquery simulation Select box, the effect is shown below:

Copy Code code as follows:

<! DOCTYPE html>
<title>jquery Simulation Select box </title>
<meta charset= "Utf-8" >
<style>
body{padding:0;margin:0;font-size:12px;}
ul,li{list-style:none;padding:0;margin:0;}
#dropdown {width:186px; margin:100px auto; Position:relative}
input_select{width:150px; height:24px; line-height:24px; padding-left:4px; padding-right:30px; border:1px Solid A9c9e2; Background: #e8f5fe URL (arrow.gif) no-repeat rightright 4px; Color: #807a62; }
#dropdown ul{width:184px; background: #e8f5fe; margin-top:2px; border:1px solid #a9c9e2; position:absolute; display: None
#dropdown ul li{height:24px; line-height:24px text-indent:10px}
#dropdown ul li A{display:block; height:24px color: #807a62; Text-decoration:none}
#dropdown ul Li a:hover{background: #c6dbfc; color: #369}
#result {Margin-top:10px;text-align:center}
</style>
<script type= "Text/javascript" src= "Http://jt.875.cn/js/jquery.js" ></script>
<script type= "Text/javascript" >
$ (function () {
$ (". Input_select"). Click (function () {
var ul = $ ("#dropdown ul");
if (Ul.css ("display") = = "None") {
Ul.slidedown ("fast");
}else{
Ul.slideup ("fast");
}
});
$ ("#dropdown ul li a"). Click (function () {
var txt = $ (this). text ();
$ (". Input_select"). Val (TXT);
var value = $ (this). attr ("rel");
$ ("#dropdown ul"). Hide ();
$ ("#result"). HTML ("You have selected" +txt+ ", the value is:" +value);
});

});
</script>
<body>

<div id= "Dropdown" >
<input class= "Input_select" type= "text" value= "Please choose City"/>
<ul>
<li><a href= "#" rel= "2" > Beijing </a></li>
<li><a href= "#" rel= "3" > Shanghai </a></li>
<li><a href= "#" rel= "4" > Wuhan </a></li>
<li><a href= "#" rel= "5" > Guangzhou </a></li>
</ul>
</div>
<div id= "Result" ></div>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.