Home Web Front-end JS Tutorial js floating layer menu collection_navigation menu

js floating layer menu collection_navigation menu

May 16, 2016 pm 06:56 PM
js menu

Instructions for use
Just reference the JS files and CSS files in the attachment to the web page, such as:

Copy code The code is as follows:




Online demohttp://img.jb51.net/online/DivMenu/DivMenu.htm
Download the source code packagehttp://img.jb51.net/online/DivMenu/DivMenu.zip
Among them, DivMenu.js is a streamlined version compressed by Javascript compressor for actual use. DivMenu_develop.js is a development version with detailed annotations for learning and research. When using it, you can refer to the comments in the DivMenu.css file and modify the style definition yourself.
The JavaScript program has been implemented as unobtrusive, that is, the HTML file that references this JS file does not need any other adjustments. However, it has not yet achieved complete anonymity, which means that this program still creates global variables and several web page nodes. It has tried to add as few global variables and nodes as possible, but please still pay attention to variable naming conflicts when using it. This program only adds one global variable "DivMenu", which adds a lot of web page nodes. Two nodes are added for each replaced SELECT node. The names are the name value of the SELECT node plus the "_a" suffix and the "_div" suffix. For example, the original name of a SELECT node is "menu", and the names of the two new nodes are "menu_a" and "menu_div".
Function description
Multi-select menus are not converted, and the prompt text in the multi-select menu can only be realized with disabled="disabled". To select multiple, please hold down the Ctrl key and select Multi-select 1 Multi-select 2 Multi-select 3 Multi-select 4 Multi-select 5 Put a multi-select menu to demonstrate that the multi-select menu will not be replaced and that the layer will be floating in IE6 It can be displayed normally on other SELECTs.
The above is a practical example, several groups of classic SELECT selection menus. The first one is complex with grouping, and the prompt text is implemented with the first option of disabled="disabled". The latter one is simple, and the prompt text is implemented with is the option without a value attribute. Practice has found that FF can normally handle disabled="disabled" or only disabled options, making it non-selectable, while IE ignores any disabled="disabled" and disabled, so it is estimated that menus in IE usually use prompt text. Use the option without value attribute or value="". You can see that its source code is the original SELECT and does not require any changes.
The basic idea is to convert the original SELECT menu in the document into a hidden INPUT form item, use A elements to make the menu's prompt text bar and option bar, use DIV layers to make the menu, and use A elements to replace each option , assign the value to the hidden INPUT form item when clicked.
Main features or limitations include:
All usage habits follow the traditional SELECT menu.
Only the single-select SELECT menu will be replaced, and the multi-select menu will remain unchanged, because usually multi-select menus are not replaced by floating menus.
Supports various SELECT element features, such as using disabled or valueless options as prompt text strips; options grouped with optgroup will also be grouped in the new menu. And it has been specially corrected for the BUG in IE 6 that SELECT blocks the DIV layer.
Supports default selected items.
Almost all functions of the ordinary menu are supported, but additional interactive functions are not supported, such as Option options created by JavaScript in real time, linkage options, etc. For example, functions such as selecting a city, district, and county will change accordingly are not supported.
All styles are defined with CSS, and font sizes use relative sizes, which can be adapted to most web pages without modification.
The menu position and size are set to be flexible and can adapt to any web page layout and layout. When doing it, the consideration was to be able to accommodate the widest option text when displayed in the replaced A element, so the width of the original SELECT box was not directly taken. Therefore, the menu size may be wider than the original SELECT, please pay attention when using it.
Welcome to try it out and provide comments and suggestions to share and discuss improvements.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use JS and Baidu Maps to implement map pan function How to use JS and Baidu Maps to implement map pan function Nov 21, 2023 am 10:00 AM

How to use JS and Baidu Map to implement map pan function Baidu Map is a widely used map service platform, which is often used in web development to display geographical information, positioning and other functions. This article will introduce how to use JS and Baidu Map API to implement the map pan function, and provide specific code examples. 1. Preparation Before using Baidu Map API, you first need to apply for a developer account on Baidu Map Open Platform (http://lbsyun.baidu.com/) and create an application. Creation completed

Recommended: Excellent JS open source face detection and recognition project Recommended: Excellent JS open source face detection and recognition project Apr 03, 2024 am 11:55 AM

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages ​​and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Dec 17, 2023 pm 06:55 PM

Essential tools for stock analysis: Learn the steps to draw candle charts in PHP and JS. Specific code examples are required. With the rapid development of the Internet and technology, stock trading has become one of the important ways for many investors. Stock analysis is an important part of investor decision-making, and candle charts are widely used in technical analysis. Learning how to draw candle charts using PHP and JS will provide investors with more intuitive information to help them make better decisions. A candlestick chart is a technical chart that displays stock prices in the form of candlesticks. It shows the stock price

How to create a stock candlestick chart using PHP and JS How to create a stock candlestick chart using PHP and JS Dec 17, 2023 am 08:08 AM

How to use PHP and JS to create a stock candle chart. A stock candle chart is a common technical analysis graphic in the stock market. It helps investors understand stocks more intuitively by drawing data such as the opening price, closing price, highest price and lowest price of the stock. price fluctuations. This article will teach you how to create stock candle charts using PHP and JS, with specific code examples. 1. Preparation Before starting, we need to prepare the following environment: 1. A server running PHP 2. A browser that supports HTML5 and Canvas 3

How to use JS and Baidu Maps to implement map heat map function How to use JS and Baidu Maps to implement map heat map function Nov 21, 2023 am 09:33 AM

How to use JS and Baidu Maps to implement the map heat map function Introduction: With the rapid development of the Internet and mobile devices, maps have become a common application scenario. As a visual display method, heat maps can help us understand the distribution of data more intuitively. This article will introduce how to use JS and Baidu Map API to implement the map heat map function, and provide specific code examples. Preparation work: Before starting, you need to prepare the following items: a Baidu developer account, create an application, and obtain the corresponding AP

How to use JS and Baidu Map to implement map click event processing function How to use JS and Baidu Map to implement map click event processing function Nov 21, 2023 am 11:11 AM

Overview of how to use JS and Baidu Maps to implement map click event processing: In web development, it is often necessary to use map functions to display geographical location and geographical information. Click event processing on the map is a commonly used and important part of the map function. This article will introduce how to use JS and Baidu Map API to implement the click event processing function of the map, and give specific code examples. Steps: Import the API file of Baidu Map. First, import the file of Baidu Map API in the HTML file. This can be achieved through the following code:

PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts Dec 18, 2023 pm 03:39 PM

With the rapid development of Internet finance, stock investment has become the choice of more and more people. In stock trading, candle charts are a commonly used technical analysis method. It can show the changing trend of stock prices and help investors make more accurate decisions. This article will introduce the development skills of PHP and JS, lead readers to understand how to draw stock candle charts, and provide specific code examples. 1. Understanding Stock Candle Charts Before introducing how to draw stock candle charts, we first need to understand what a candle chart is. Candlestick charts were developed by the Japanese

How to use JS and Baidu Maps to implement map polygon drawing function How to use JS and Baidu Maps to implement map polygon drawing function Nov 21, 2023 am 10:53 AM

How to use JS and Baidu Maps to implement map polygon drawing function. In modern web development, map applications have become one of the common functions. Drawing polygons on the map can help us mark specific areas for users to view and analyze. This article will introduce how to use JS and Baidu Map API to implement map polygon drawing function, and provide specific code examples. First, we need to introduce Baidu Map API. You can use the following code to import the JavaScript of Baidu Map API in an HTML file

See all articles