|
-
May 5th, 2010, 12:21 PM
#1
javascript - need suggestions with getting specific elements from container
hi,
here is what i want to do:
e.g.
Code:
<div id="container">
<h1>text</h1>
<p>text</p>
<p>text</p>
<p>text</p>
<p>text</p>
<p>text</p>
<random tag></<random tag>>
.
.
.
<h1>text</h1>
<p>text</p>
<p>text</p>
.
.
.
</div>
i want to get list of all h1 and p, but i need to preserve order e.g h1pppppppph1ppppph1pp,
i can do this by getting all elements and then check if element.tagName == "h1" but this way i will check hundreds of elements that i dont need while getting only few h1 and p, is there a way to optimize it, or maybe better approach ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|