The function of $(id) {
Return typeof id==='string'? Document. The getElementById (id) : id;
}
Var titles=$(" notice - tit "). The getElementsByTagName (" li ");
Var divs=$(" notice - con "). The getElementsByTagName (" div ");
for(var i=0; i
Titles [I] onm ouseover=function () {
For (var j=0; j
Divs [j] style. The display="none";
}
Enclosing the className="tab_current";
Divs [this index]. Style. The display="block";
};
};
</script>
CodePudding user response:
<script>The function $(id) {//transfer an id, enclosed document.
getElementById methodReturn typeof id==='string'? Document. The getElementById (id) : id;//figure out whether variable id string type, so, according to the id, access to objects, not directly return variable id
}
Var titles=$(" notice - tit "). The getElementsByTagName (" li ");//get notice - all tile object under li
Var divs=$(" notice - con "). The getElementsByTagName (" div ");//get all the div of notice - con
for(var i=0; i
Titles [I] onm ouseover=function () {//mouse across events, slip into the corresponding li, remove the style of li, hidden for div
For (var j=0; j
Divs [j] style. The display="none";
}
Enclosing the className="tab_current";//set the style of li to tab_current
Divs [this index]. Style. The display="block";//display the corresponding div
};
};
</script>
CodePudding user response:
This you can also write a test program, using this method, take a look at will know that what is the functionCodePudding user response: