JavaScript DOM Programming Art

Source: Internet
Author: User

Involves the Quick access key (accesskey property) feature:
Add the following code to the HTML page:

<ul id= "Navigation" >    <li><a href= " Ape Group Education " accesskey= "1" >Home</a></li>    <li><a href= "search.html" accesskey= "4" >search</a></li>    <li><a href= " Contact.html "accesskey=" 9 ">contact</a></li></ul>


JS Add a method to display:

function Displayaccesskeys () {if (!document.getelementsbytagname | |!document.createelement | |!    document.createTextNode) return false;    var ul = document.getElementById ("navigation");    var links = ul.getelementsbytagname ("a");    var Akeys = new Array ();        for (Var i=0;i<links.length;i++) {if (!links[i].getattribute ("accesskey")) continue;        var key = Links[i].getattribute ("accesskey");        var text = Links[i].lastchild.nodevalue;    Akeys[key] = text;    } var list = document.createelement ("ul");        For (key in Akeys) {var text = Akeys[key];        var str = key + ":" + text;        var item = document.createelement ("Li");        var item_text = document.createTextNode (str);        Item.appendchild (Item_text);    List.appendchild (item);    } var Header = document.createelement ("h3");    var header_text = document.createTextNode ("Accesskeys");    Header.appendchild (Header_text);    Document.body.appendChild (header); Document.body.appendCHild (list);} 


Note: JavaScript scripts should only be used to enrich the contents of the document, avoiding the use of DOM technology to directly insert core content.

JavaScript DOM Programming Art

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.