Why does the result of getting elements by ID in javascript output null or object HTMLParagraphElement? -PHP Chinese website Q&A-Why is null or object HTMLParagraphElement output when getting elements through ID in javascript? -PHP Chinese website Q&A
Why does the result of getting elements by ID in javascript output null or object HTMLParagraphElement? -PHP Chinese website Q&A-Why is null or object HTMLParagraphElement output when getting elements through ID in javascript? -PHP Chinese website Q&A
Please watch and learn.
这里获取的元素是一个对象,输出是显示的是一个P元素对象。如想对元素进行操作,我们要通过它的属性或方法。如,我们要输出p元素的内容,那么就得用innerHTML属性。