473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Javascript : selecting elements within a element

chathura86
227 100+
i want to select all ul tags with in a given div tag

eg.
Expand|Select|Wrap|Line Numbers
  1. <div id="a">
  2.     <ul>
  3.           <li>asdad .....</li>
  4.           <ul>
  5.                  <li>asdad .....</li>
  6.                  <li>asdad .....</li>
  7.                  <li>asdad .....</li>
  8.           </ul>
  9.           <ul>
  10.                  <li>asdad .....</li>
  11.                  <li>asdad .....</li>
  12.                  <li>asdad .....</li>
  13.           </ul>
  14.     </ul>
  15. </div>
  16.  
so i want select only the ul tags in the javascript
cannot use id for ul tags because they are generating dynamically
and there are other ul tags out side this div tag

chathura bamunusinghe
May 23 '08 #1
3 1751
acoder
16,027 Expert Mod 8TB
Use the getElementsByTagName method on the div:
Expand|Select|Wrap|Line Numbers
  1. var uls = document.getElementById("a").getElementsByTagName("ul");
May 23 '08 #2
chathura86
227 100+
it works
thank you very much
May 23 '08 #3
acoder
16,027 Expert Mod 8TB
You're welcome :)
May 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.