Home >
Web Front-end >
JS Tutorial >
JavaScript DOM programming examples (Zhi Podcast Learning)_javascript skills
JavaScript DOM programming examples (Zhi Podcast Learning)_javascript skills
WBOY
Release: 2016-05-16 18:41:28
Original
1029 people have browsed it
He also explained to us a lot of methods on how to learn DOM, and I think it was really beneficial. Here are a few examples that I think are better to share with you. 1. Second-level linked drop-down menu (the first level is the province, the second level is the city, it is required to select the province at the first level, and the second level city appears accordingly) Steps: 1) Basic framework (HTML): two complex check box, and there should be no options in the second check box. Note that the first drop-down box will be used as the event source, and the function implementation part in JavaScript will be stimulated through the onchange method.
2) Page modification does not require too much, just let the drop-down menu display one 3) To implement functions through JavaScript, we want to be the first Select a province from a drop-down list, and its city can be directly displayed later. Seeing this one-to-many correspondence, we first thought of the container map collection, but JavaScript does not have a map collection, so we thought of a container such as an array, and finally decided Use a two-dimensional array to help us implement this function.
Summary: Remember to clear the array every time. 2. Mailing list Thoughts: 1) First of all, when you think of the overall framework, you will definitely think of using tables for formatting, and then realize related functions by operating tables and nodes such as rows and cells 2) css The main thing is to format the table, and the second thing is to select and display different effects on two rows, which is achieved by dynamically modifying the className. Due to the length, the html and css part of the code is relatively simple, so it will not be embarrassing. 3) JavaScript to implement various functions, the code is as follows:
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