javascript- element operation

## js acquisition html tags
acquired individual labels:
var document.getElementsByID ELE = ( "")

Gets an array of multiple labels:
document.getElementsByTagName ( "")
document.getElementsByClassName ( "")

Get read tag content:
ele.innerHTML: reading or setting element may identify text label syntax (redecoration)
ele.innerText: Sets the element does not recognize the text label syntax
ele.value: reading or setting the value of the form control

Get property tag read:
elem.getAttribute ( "attrName"); // returns the attribute name corresponding to the specified attribute value elem.attrname
elem.setAttribute ( "attrName", "value"); // add attributes for the element, argument is the name and value = elem.attrname "value"
elem.removeAttribute ( "attrName"); // Removes the specified property elem.attrname = null


Modify the style of an Element:

= elem.style.width '100px'
elem.style.display = 'none' to completely hide the entire contents of the label

 

 

Guess you like

Origin www.cnblogs.com/chenlulu1122/p/11888833.html
Recommended