Home > front end >  [to appear on the page object HTMLDivElement] is what mean?
[to appear on the page object HTMLDivElement] is what mean?

Time:10-09



I don't understand [object HTMLDivElement] what is this, an error?
Why not output the DIV?



 


<meta HTTP - equiv="content-type" Content="text/HTML. Charset=utf-8 "/& gt;
Anonymous functions & lt;/title> <br/><style> <br/># div1 {<br/>width: 100px; <br/>height: 100px; <br/>Background - color: black. <br/>color: white; <br/>} <br/></style> <br/></head> <br/><script> <br/>Window. The onl oad=function () {<br/>Var avc=document. GetElementById (" div1 "); <br/>Document. The write (avc); <br/>} <br/><br/>Var a=function () {<br/>Alert (" good trapped!!!!!!!!!!! "); <br/>} <br/><br/>(a); <br/></script> <br/><br/><body> <br/><Div id="div1" & gt; Sogou pinyin input method & lt;/div> <br/></body> <br/><br/></html> <br/></pre> <br/><br/><img SRC="https://img.codepudding.com/202010/140155092324481.png" Alt=""/> <br/><p class="article - content rp"> CodePudding user response: </p>Document. The getElementById (" div1 ") this is an object that you put the object output out, if you want to display content div, to the document. The write (avc) innerHTML); such<p class="article - content rp"> CodePudding user response: </p>Upstairs positive solution, <br/>Actually like this kind of problem, as long as the building Lord F12 debugging will know right away<p class="article - content rp"> CodePudding user response: </p>Not wrong, just your output as an object<p class="article - content rp"> CodePudding user response: </p>Output is the dom object, <br/>It is recommended to use the console. The log () outputs the, F12 can debug, also can open object, to see all properties and methods <br/><p class="article - content rp"> CodePudding user response: </p>[object HTMLDivElement] : <br/>Returns the full name of the div element <br/>If you want to access the contents of the div element. Please add the innerHTML eg: var avc=document. The getElementById (" div1 "). The innerHTML<p class="article - content rp"> CodePudding user response: </p>Var avc=document. GetElementById (" div1 "); <br/>Document. The write (avc); <br/>Instead of <br/>Var avc=document. GetElementById (" div1 "). The value; <br/>The document. The write (avc) value);<p class="article - content rp"> CodePudding user response: </p>To add a innerHtml behind when getting elements; Otherwise you are stored objects, </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/59645.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/59645.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/59644.html'>How to implement webrtc MediaStream object reuse</a></div> <div class="detail-arr-right">Next:<a href='/frontend/60120.html'>The article slip</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=JavaScript' target='_blank'>JavaScript</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>