01 JS Basics

1. Get Get the value of the property.

The getAttribute() method gets the value of an attribute by name.
demo:
<a href="dom_obj_attributes.php" target="A">Attr 对象</a>
var a=document.getElementsByTagName("a")[0];
a.getAttribute("href"); //Get A

2. Get the content in the tag.

The innerHTML property sets or returns the HTML between the table row's opening and closing tags.
demo:
< th id ="tr1" > Firstname </ th > 
alert(document.getElementById("tr1").innerHTML); //Get Firstname 

1.innerText //Print the plain text information between tags, the tags will be filtered Drop  
2.innerHTML //Print the content between tags, including tags and text information  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324461184&siteId=291194637