[Javascript] Something better than getElementById

Terry Riegel riegel at clearimageonline.com
Fri Oct 21 19:08:12 CDT 2005


I have a page that uses the code pasted below

---
      var a = document.getElementById(dest);
      a.className='sel'
      document.browseform["fm_list"].value = "|"+dest+b;
      document.browseform["fm_cmd"].value = "";
      document.browseformhere["fm_cmd"].value = "";
      document.browseformhere["fm_list"].value = "|"+dest+b;
      document.browseform.submit();
---



The only reason I need to getElementById is to set the background  
color to indicate the link is selected. Is there a way to set an  
attribute without looking up the id? I am looking for ways to speed  
up my pages, some have hundred's of ID's.

Something like MyParentDiv.className='sel'



Here is the HTML

---
<div class="nor" id="images">
  <a href="javascript:changedest2('images','DIR')"><img src="/ 
clearimage/images/dir-small.gif" border="0" width="12" height="12"  
align="left"></a>
  <a href="javascript:changedest('images','DIR')"  
ondblclick="changedest2('images','DIR')">images</a>
</div>
---



More information about the Javascript mailing list