Question:

Want a replacement for getelementbyid in javascript dom?

by  |  earlier

0 LIKES UnLike

in javascript to get the document object such as div i will use getelementbyid witt the id of the div. but instead of that i want to give directly sucha as window.document.<div_id> . but by giving this its not working.. please help me gettng the addres of the div directly instead of searching

 Tags:

   Report

2 ANSWERS


  1. Try getElementByClass. Or getElementsByName, getElementsByAttribute, getNodesByType &amp; getElementsByTagName.

    Ron


  2. You can&#039;t do it that way, you have to use a get method. Using a form and using document as the means are quite different. Also keep in mind that many tags work in vastly different ways (i.e. input use &quot;value&quot; while divs use &quot;innerHTML&quot; or &quot;textContent&quot;). Somethings just will not work.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions