JavaScript Learning (three) - DOM foundation

1, access to DOM elements

document.getElementById ( "ID"): Get all the elements in the document ID, the prerequisite is to have an ID tag

document.getElementByTagName ( "Tag"): Gets Tag label (like li, ul, div, etc.) at all elements of the return value is an array, there is no style attributes

When the two mix, document.getElementById ( "ID"). GetElementByTagName ( "Tag"), note that the second document would not increase, because it is the first look at the premise of the second element

2. Set the style DOM element

DOM value .style.styleName = "styleValue": Note styleName not have a separator , is an array of elements, must be traversed to become a single element to set the style, the style must be provided prior to the acquired element

Guess you like

Origin www.cnblogs.com/shary-blue/p/11105357.html