Better Way To Traverse Doc?
Jul 13, 2009There has got to be a better way to traverse a doc than this code...
View 5 RepliesThere has got to be a better way to traverse a doc than this code...
View 5 RepliesI am pretty new to jQuery, so apologies for such a basic question. But, it seems to me, the DOM is a hierarchical data set, and jQuery runs up and down this set in order render many of its results.I would like to understand, therefore, what method(s) jQuery uses to traverse the DOM. Is it using some form of indexing - a radix tree maybe?Developing the thought, I am wondering if there are any caching or optimisation steps I could take to help it along.I ask because a) I am always curious about these things b) I would like to write the best code I can based upon as much information as I can get and c) I am starting to use Ajax and, it seems to me, that the sequence and timing of asynchronous requests needs to be carefully thought through. If requests to the DOM can ever conflict (logically or otherwise) with requests to a server, I would like to understand how it all works.
View 3 Replies View RelatedI have an array called "Prods". Here are the different values in that array:
ProductName, HowManyCalories, ProductImage, LinkFromImage, Description, Price, BuyLink
There are a number of products. I'm just wondering how do I use "ProductName" as a product key to output its unique values?
Eg. the ProductName is "Chocolate Spread" - how do I output the "HowManyCalories" and "Product Image" only from the "Prods" array, based on the key "Chocolate Spread"?
Unfortunately, I couldn't find any way to traverse the object array in
reverse order. I'd thought there must be a way to do it with for..in
loop, but couldn't find anything yet.
i have something like that as menu:
<div id='main_div'>
<ul class='ul_main current'>
<li class='level1 item1'>item 1</li>
<li class='level1 item2 current'>item 2
<ul>
<li class='level2 item1'>item 2.1</li>
[Code]...
If I have the following in my document
<DIV id="leftdiv">
<DIV id="innerDiv1">
<DIV id="innerDiv1a">
<input id="input1">
</DIV>
</DIV>
</DIV>
How would I get a reference to the input1 element using "getElementById"?
I'm trying (document.getElementById("leftdiv")).document. ..
I'm working on an image gallery at the moment and I'm having some trouble with the array the the images are stored in. The issue I'm having is that I can't figure out how to increase and decrease the current element in an array with the onclick event. Here's what I'm thinking so far:
var imageList = ['a','b','c','d','e'];
var position=0;
currentImage=imageList[position];
if a link with the id of "leftClick" is clicked, then position should decrease by 1 but if a link with the id of "rightClick" is clicked, then position should increase by 1 Both of these conditions should be bound to imageList.length i.e. if (position<0){position=0}; and if (position>imageList.length){position=imageList.length}; So how can I make "position" increase or decrease by clicking a link using the onclick event?
Can jquery be used to read/traverse a xml file?
View 2 Replies View RelatedI am new to jQuery.I have a problem where I want to traverse through DOM.For example a complete webpage.Is there any jQuery way to traverse complete DOM of the current page where the jQuery script resides ?
View 3 Replies View RelatedConsider the following snippet of [code]...
I would expect it to show "2" but instead it shows "0". Why?
It seems the find() method doesn't work on the newly created elements. Do traversing methods only work on elements that are actually in the document? If so, how can I traverse and manipulate freshly created elements prior to inserting them into the dom?
I'm getting some XML back from an ajax call ... it's working as expected.My problem/question is that I don't know how to traverse the XML properly using Jquery.This is what I'm getting back:
<media>
<photos>
<photo id="1" size="s">url/photo1-s.jpg</photo>[code]....
My code currently uses $(this).find("photos").each(function() to get each of the photos, and that works fine.However, the list of photos can be quite large, and I really don't need them all -I'd like to just "grab" the one or two photos I know I need based on the id and size attributes. Is this possible without going thru the entire list?
I have an iFrame on a page where I am calling .mouseup(function()) on it's document child.Once in the mouseup function, I need to refer to a specific sibling of the iFrame.Unfortunately, I cannot figure out how to traverse backwards to the iFrame element from $(this) - where $(this) is the document. I get a null set returned when I try$(this).parents().
View 1 Replies View Related