Reputation:
I have some bookmarks that are displayed as pages. I need to search these pages for a particular page in this case - page with id "social_page".
So to start, I grab the containing div
var bookmark_fill = document.getElementById( 'bookmark_fill' );
How do I best traverse the "pages" in bookmark_fill? This simple case below has only 2 pages.
Upvotes: 1
Views: 294
Reputation: 83358
To get your bookmark_fill node:
var bookFill = document.getElementById("bookmark_fill");
To get all the pages in there, you can use the getElementsByClassName
method
var allBookMarkPages = bookFill.getElementsByClassName("bookmark_page");
for (var i = 0, max = allBookMarkPages.length; i < max; i++) {
var allLinks = allBookMarkPages[i].getElementsByClassName("bookmark");
}
Upvotes: 1
Reputation: 78520
var socialPage = document.getElementById("social_page");
because ID's are supposed to be unique.
Upvotes: 4