Usually, we use document.getElementById to get the element node. As the general JavaScript object, it naturally has its properties like innerHTML and methods like setAttribute. But, it has so many properties, what should we do to classify them? Well, we can consider if the property belongs to itself or not. For example, the style and the innerHTML properties is belong to, but the childNodes, the parentNode,the previousElementSibling and nextElementSibling are not.
Some common properties like class and id, we can simply get and set it by element.class and element.id, for another properties like name and title, we can customize and visit it by setAttribute and getAttribute.
网友评论