Wednesday, October 19, 2011

To find elements , no of elemtents .

document.write(document.anchors.length); // find all anchors on page
if yo have more than 2 forms
document.write(document.forms[0].name); // for first form name
document.write(document.images.length);// all images
document.write(document.cookie);// find cookies
 var x=document.getElementsByName("x");
  alert(x.length);// find no of elements on a page
getElementById() Accesses the first element with the specified id
getElementsByName() Accesses all elements with a specified name
getElementsByTagName() Accesses all elements with a specified tagname

No comments:

Post a Comment