JS simulation to implement Select effect code_javascript skills
May 16, 2016 pm 03:37 PMThe example in this article describes the JS simulation to implement the Select effect code. Share it with everyone for your reference. The details are as follows:
A Select effect is simulated here. In fact, this is not a simulation, but a self-made Select. With the cooperation of JavaScript, CSS UL/LI is used to form a drop-down list, similar to the effect of a drop-down Select. You can modify them at will. The colors and contents are more convenient to use.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-mn-select-style-demo-codes/
The specific code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>模拟Select效果</title> </head> <body> <style> ul,li{list-style-type:none;padding:0;margin:0;} .select{width:200px;height:22px;line-height:22px;border:1px solid #dcdcdc;} #text_left{display:block;width:180px;float:left;padding:0 5px;} #arrow_right{ display:block; border-color:#FF6600 #FFFFFF #FFFFFF #FFFFFF; border-style: solid; border-width: 4px; display: block; font-size: 0; height: 0; line-height: 0; width: 0; float:left;margin-top:8px; cursor:pointer; } .list{width:200px;border:1px solid #dcdcdc;border-top:0;display:none;} .list li{line-height:24px;padding:0 5px;} .list li:hover{background:#F8F3F4;cursor:pointer;} </style> <div class="select"> <span id="text_left">脚本之家</span> <span id="arrow_right"></span> </div> <ul class="list"> <li>新浪新闻</li> <li>腾讯门户</li> <li>凤凰影视</li> <li>奇艺高清</li> </ul> <script type="text/javascript" src="jquery-1.9.1.min.js"></script> <script type="text/javascript"> $(function(){ $('#arrow_right').click(function(e){ $('.list').toggle(); e.stopPropagation(); $('body').click(function(){ $('.list').hide(); }) }) $('.list li').click(function(){ $('#text_left').text(($(this).text())); }) }) </script> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use JS and Baidu Maps to implement map pan function

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS

Recommended: Excellent JS open source face detection and recognition project

PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts

How to create a stock candlestick chart using PHP and JS

How to use JS and Baidu Maps to implement map polygon drawing function

How to use JS and Baidu Map to implement map click event processing function

How to use JS and Baidu Maps to implement map heat map function
