SetAttribute (), setattribute
● Nodes are divided into different types: Element nodes, attribute nodes, and text nodes.● The getElementById () method returns an object that corresponds to a specific element node in the document.● The
Analysis on setAttribute compatibility usage in javascript and setattribute compatibility
This article analyzes the setAttribute compatibility usage in javascript. We will share this with you for your reference. The details are as follows:
1: We
Next I will share with you a tutorial on the usage of Attribute and setAttribute in Javascript. I hope this article will help you.
First, let's talk about setAttribute. We often need to dynamically add various attributes to the Element in JavaScript.
We often need to dynamically add various attributes to the Element in JavaScript, which can be achieved by using setAttribute (), which involves the compatibility of the browser. SetAttribute (stringname, stringvalue): Add a new attribute with the
In general, I feel that js setAttribute works exactly the same as attr in jquery, but it is simplified in jquery and the work is more powerful. Next I will introduce their usage separately.
SetAttribute (string name, string value): adds a new
We often need to dynamically add various attributes to the element in Javascript, which can be achieved by using setattribute (), which involves the compatibility of the browser.
Setattribute (string name, string value): adds a new attribute with
We often need to dynamically add various attributes to the Element in JavaScript, which can be achieved by using setAttribute (), which involves the browser compatibility problem setAttribute (string name, string value ): add a new attribute with
GetAttribute () method
So far, we have introduced two methods to retrieve specific element nodes: getElementById () and getElementsByTagName. After finding the element, we can use the getAttribute () method to query the values of its various
A document is a node tree.
Nodes are divided into different types: Element nodes, attribute nodes, and text nodes.
The getelementbyid () method returns an object that corresponds to a specific element node in the document.
The getelementsbytagname ()
The previous article in this series examined the concepts involved in the Document Object Model (DOM) programming-How web browsers regard web pages as a tree. Now you should understand the programming structure used in Dom. In this tutorial, we will
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.