_javascript Tips for space-generated errors in JavaScript development

Source: Internet
Author: User
No more nonsense, first on the code for everyone to see
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv=" Content-type " Content= "text/html; Charset=utf-8 "/>
<title> yiyi corner </title>
<body>
<div id=" Win "&G T
<ul id= "Picchange" >
<li>
</li>
<LI&G T
</li>
<li>
</li>
</ul>
</div>
<script type=" Text/javascript ">
var pic = document . getElementById (' Picchange ');
var piclist = pic.getelementsbytagname ("Li");
Alert (piclist[0].firstchild);
</script>
</body>

Above code 1 please respectively in Firefox and IE Run, Firefox appears is [object Text], and IE appears is [object], here IE and Firefox all put Piclist[0]. FirstChild This object as objects, Firefox hint is the text type object, IE no hint finer.
We then run the following section of the code to see, see, the code itself is the same, but Li did not do line indent below.
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Yiyi Garden </title>
<body>
<div id= "Win" >
<ul id= "Picchange" >
<li></li>
<li></li>
<li></li>
</ul>
</div>
<script type= "Text/javascript" >
var pic = document.getElementById (' Picchange ');
var piclist = pic.getelementsbytagname ("Li");
alert (piclist[0].firstchild);
</script>
</body>

Above code 2 please respectively in Firefox and IE Run, Firefox appears is [object Htmlimageelement], and IE appears is [object], here IE and Firefox all put Piclist[0]. FirstChild This object as objects, Firefox hint is htmlimageelement type object, IE no hint finer.
The upper and lower two types of writing just indentation and line change, in IE is recognized as the object, but the different indentation in Firefox but represents a different object, Firefox interpretation of the HTML is really confusing.
This record, I hope that friends see useful, do not have the same problem with me for half a day did not find a way to solve the problem.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.