In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the example analysis of the JavaScript HTML DOM document object model, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
HTML DOM
Through HTML DOM (document object Model), you can access all elements of an JavaScript HTML document.
When a web page is loaded, the browser creates a document object model (Document Object Model) for the page.
The HTML DOM model is constructed as a tree of objects.
Through the programmable object model, JavaScript gains enough power to create dynamic HTML.
JavaScript can change all HTML elements in a page
JavaScript can change all HTML properties in a page
JavaScript can change all CSS styles in a page
JavaScript can react to all events on the page
Find the HTML element
Typically, with JavaScript, you need to manipulate the HTML element.
In order to do this, you must first find the element. There are three ways to do this:
Find the HTML element through id
Find the HTML element by signing the tag
Find the HTML element by the class name
Find HTML elements through id
The easiest way to find a HTML element in DOM is by using the element's id.
Hello World!
This example demonstrates the getElementById method!
X=document.getElementById ("intro"); [xss_clean] ("
The text in the paragraph of id= "intro" is: "+ x [XSS _ clean] +"
")
Note: if the element is found, the method returns the element as an object (in x).
Tip: if the element is not found, x will contain null.
Find HTML elements by signature
This example looks for the elements of id= "main" and then finds all the elements in "main"
Elements:
Hello World!
The DOM is very useful.
This example demonstrates the getElementsByTagName method.
Var x=document.getElementById ("main"); var y=x.getElementsByTagName ("p"); [xss_clean] (the first paragraph of the div in which "id is" main "is:" + y [0] [xss_clean]); this is all the content of the article "sample Analysis of the JavaScript HTML DOM document object Model". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.