Thanks Matt. I was planning to use same element id/name on different <div>
in the html. I guess I'll scratch tht idea and do what you suggested.

"Matt Lavinder" <mlavinder@xxxxxxxxxxxxxxxxxxx> wrote in message
The following should work fine:


If you this is an issue because you are creating elements with duplicate
names, it is allowed but considered bad practice. I would recommend
a counter of something similar so that all the "id" attributes are unique.
When you want to group elements together using an attribute, use "class"
"name" - keep ID unique and your life will be a lot easier.

That all said, if you want to dig out a specific element within a DIV, it
can be done but it is a little extra work. You would have to loop through
all the elements until you find the one with a matching ID. Having a
ID for each element is usually a much simpler way of handling things.

On Thu, Jun 9, 2011 at 2:35 PM, Hockchai Lim

Do anyone know how I can use js to get DOM element within a <div>. I
below but it does not work:

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

This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives

This thread ...


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

This mailing list archive is Copyright 1997-2020 by 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].