getElementByIdgetElementByClass
getElementByClass
<html><head><!--This is the TOGGLE script--><script type="text/javascript"><!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}//--></script></head><!--the XML/XSLT page contents will be loaded here, with DIVs named by Class separating dozens of li's-->
<a href="#" onclick="toggle_visibility('class1');">Click here to toggle visibility of class 1 objects</a>
<a href="#" onclick="toggle_visibility('class2');">Click here to toggle visibility of class 2 objects</a></body></html>如何用JavaScript实现ElementByClass而不是GetElementById?
相关分类