A bug in Firefox's childNodes processing of the tab function on msn

Source: Internet
Author: User

A bug in Firefox's childNodes Processing
ChildNodesFirefox does not filter line breaks and spaces when processing childNodes. Therefore, the first time you use it, the expected results are not.
HTML
Copy codeThe Code is as follows:
<Ul class = "tbtn" ID = "menuList">
<Li class = "curr" id = "tabap3_btn_0" onclick = "tabit (this)"> Finance University B </li>
<Li id = "tabap3_btn_1" onclick = "tabit (this)"> medical lecture hall </li>
<Li id = "tabap3_btn_2" onclick = "tabit (this)"> medical lecture hall </li>
<Li id = "tabap3_btn_3" onclick = "tabit (this)"> medical lecture hall </li>
<Li class = "lst" id = "tabap3_btn_4" onclick = "tabit (this)"> film hotspot </li>
</Ul>

JS
Copy codeThe Code is as follows:
Function tabit (btn)
{
Var idname = new String (btn. id );
Var s = idname. indexOf ("_");
Var e = idname. lastIndexOf ("_") + 1;
Var tabName = idname. substr (0, s );
Var id = parseInt (idname. substr (e, 1 ));
Var tabNumber = btn. parentNode. childNodes. length; // The values of IE and FF are different.
For (I = 0; I <tabNumber; I ++)
{
If (document. getElementById (tabName + "_ div _" + I )! = Null) // you need to determine
{
Document. getElementById (tabName + "_ div _" + I). style. display = "none ";
Document. getElementById (tabName + "_ btn _" + I). style. backgroundImage = "url (pic/t-1-2.gif )";
Document. getElementById (tabName + "_ btn _" + I). style. borderBottomColor = "# D7F2DA ";
Document. getElementById (tabName + "_ btn _" + I). style. cursor = "pointer ";
}
}
Document. getElementById (tabName + "_ div _" + id). style. display = "block ";
Btn. style. backgroundColor = "# fff ";
Btn. style. borderBottomColor = "# fff ";
Btn. style. cursor = "default ";
}

On IE, the value of childNodes. length of menuList is 5, and the value of Firefox is 11. Therefore, when using the childNodes object, we need to judge it first or remove spaces.

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.