Note that you will probably want to use the innerHTML DOM element and not
the value element. Use value only for form fields.
If you are trying to get the value from within a div tag like this:
<div id="myDiv">My text</div>

then use this:

var myDiv = document.getElementById('myDiv').innerHTML;

Thanks,
Todd Allen
Estes Express Lines
tallen@xxxxxxxxxxxxxxxxx




"Hockchai Lim"
<lim.hock-chai@us
amobility.com> To
Sent by: web400@xxxxxxxxxxxx
web400-bounces@mi cc
drange.com
Subject
[WEB400] javascript - use
2011-06-09 14:34 getElementById to get element
within a div

Please respond to
Web Enabling the
AS400 / iSeries
<web400@midrange.
com>






Do anyone know how I can use js to get DOM element within a <div>. I tried

below but it does not work:

var myDiv = document.getElementById('myDiv');
alert(myDiv.getElementById('elemInMyDiv').value);


For 80 Years — Delivering Solutions that Exceed Expectations.
This communication and any transmitted documents are intended to be confidential. If there is a problem with this transmission, please contact the sender. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.