Dom Settings table interlacing JS code and mouse hover on which line, which line font is bold effect

Source: Internet
Author: User

/* P#example{color:grey; font:18px ' Arial ', Sans-serif;} */body{font-family: "Helvetica", "Arial", Sans-serif; background: #fff; color: #000}table{margin:auto; border:solid 1px #699; Text-align:center; width:600px;} caption{Margin:auto; padding:10px; font-weight:bold;} Th{background: #9cc; font-weight:normal; padding:5px; border:1px dotted #699; height:40px;} /* Tr:nth-child (ODD) {background: #ffc;} Tr:nth-child (even) {background: #fff;} interlace color */td{height:40px;}
<! Doctype html>
Function addloadevent (func) {    //does not matter how many functions are executed after the page is loaded var oldonload =  window.onload;if (typeof window.onload !=  ' function ') {Window.onload = func;} Else{window.onload = function () {oldonload (); func ();}}} Function stipetables () {if (!document.getelementsbytagname)  return false;var tables =  document.getelementsbytagname ("table"); Var odd,rows;for (var i = 0; i <  tables.length; i++) {odd = false;rows = tables[i].getelementsbytagname ("tr"); (var j = 0; j < rows.length; j++) {if (odd == true) {rows[j].style.backgroundcolor =  "#ffc"; odd = false;} Else{ odd = true;}}}} Function displayabbreviations () {//Check compatibility if (!document.getelementsbytagname| |! Document.createelement| |! document.createTextNode)  return false;var abbreviations = docUment.getelementsbytagname ("abbr");      //get all acronyms if (abbreviations.length < &NBSP;1)  false;                          //compatible with IE6 and the following low-version browsers, allowing the loop to continue var defs =  New array (); for (var i=0; i < abbreviations.length; i++) {                   //Traverse these acronyms var  Current_abbr = abbreviations[i];var definition = current_abbr.getattribute ("title"); Var key = current_abbr.lastchild.nodevalue;defs[key] = definition;} Var dlist = document.createelement ("DL");                    //Create definition list   for ( key in  defs) {                                           // Traversal definition var definition = defs[key]; var dtitle = document.createelement ("DT");                   // Create a definition title Var dtitle_text = document.createtextnode (key);d Title.appendchild (dtitle_text);var  Ddesc = document.createelement ("DD");                     //Create definition Description var ddesc_text =  document.createTextNode (definition);dd esc.appendchild (ddesc_text);                                 //add them to the definition list dlist.appendchild (dtitle);d list.appendchild (DDESC);} /* if (dlist.childnodes.length < 1)  return false;                 //in the lower version of the browser, because the defs array is empty, So immediately exit Displayabbreviations function  */var header = document.createelement ("H2");                    // Create the title Var header_text = document.createtextnode ("abbreviations"); Header.appendchild (Header_text); Document.body.appendChild (header);                            // Add title to page body Document.body.appendChild (dlist);            The                  //willThe semantic list is added to the principal}addloadevent (stipetables); addloadevent (displayabbreviations);//mouse moves to a line, the line text is bold, the effect is equivalent to tr:hover{ Font-weight:bold;} Function highlightrows () {if (!document.getelementsbytagname)  return false;var rows =  document.getelementsbytagname ("tr"); for (var i = 0; i < rows.length;  i++) {rows[i].onmouseover = function () {this.style.fontweight =  "bold";} Rows[i].onmouseout = function () {this.style.fontweight =  "Normal";}} Addloadevent (highlightrows);

The browser effect is as follows:

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/82/07/wKioL1dIE0PjIDztAAA3Ny1YBWM966.png-wh_500x0-wm_3 -wmp_4-s_1323882075.png "title=" Qq20160527172350.png "alt=" Wkiol1die0pjidztaaa3ny1ybwm966.png-wh_50 "/>

Dom Settings table interlacing JS code and mouse hover on which line, which line font is bold effect

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.