Simulate Select drop-down box with Div,ul,input

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "Utf-8" />5 <title>Case Test</title>6 <Linkrel= "stylesheet"href= "Css/all.css" />7 <Scripttype= "Text/javascript"src= "Js/jquery-1.7.2.min.js"></Script>8 <Scripttype= "Text/javascript"src= "Js/all.js"></Script>9 Ten </Head> One  A <Body> - <!--End Simulation drop-down box - - <Divclass= "Select"> the     <Divclass= "Input_in"> -         <inputtype= "text"value= "D.C" /> -     </Div> -     <Divclass= "City Hide"> +         <ul> -             <Li>New York1</Li> +             <Li>New YORK2</Li> A             <Li>New York3</Li> at             <Li>New York4</Li> -             <Li>New York5</Li> -             <Li>New York6</Li> -         </ul> -     </Div> - </Div> in <!--End Simulation drop-down box - - </Body> to  + </HTML>
1 /*Public Style*/2 * {padding:0;margin:0;List-style:None;font-size:14px; }3 . Hide{Display:None; }4 input{Outline:None; }5 6 /*simulate drop-down box*/7 . Select{position:relative;margin:50px 0 0 100px; }8 . Select. Input_in input{width:188px;Height:20px;Line-height:20px;padding:10px 0 10px 10px;Border:1px solid #d6d6d6;cursor:Pointer; }9 . Select. City{position:Absolute;Top:40px; Left:0; }Ten . Select. City UL{width:198px;Border:1px solid #d6d6d6;Border-top:None; } One . Select City ul Li{Padding-left:10px;width:188px;Height:40px;Line-height:40px;cursor:Pointer; }
1$(function(){2 3 //simulate drop-down box4$ ('. Select Input '). On (' click ',function(){5         if($ ('. Select. "). is ('. Hide '))){6$ ('. Select. City '). Removeclass (' Hide ');7}Else{8$ ('. Select. City '). addclass (' Hide ');9         }Ten     }) One$ ('. Select Ul li '). On (' click ',function(){ A$ ('. Select Input '). Val ($ ( This). HTML ()); -$ ('. Select. City '). addclass (' Hide '); -$ ('. Select Input '). CSS (' border-bottom ', ' 1px solid $d 6d6d6 '); the     }) -$ ('. Select Ul li '). Hover ( -         function(){ -$( This). css ({' backgroundcolor ': ' #fd9 ', ' font-size ': ' 18px ')}); +},function(){ -$( This). css ({' backgroundcolor ': ' #fff ', ' font-size ': ' 14px ')}); +         } A     ) at  -  -  -      -      -})

Simulate Select drop-down box with Div,ul,input

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.