leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Traversing DOM

I am from the E4X world and it's a little difficult for me to transition to JQuery syntax. I've been trying to transverse the DOM here without success. Using these has produced no success to navigate the elements:
codealert($(data).text()); == to get the whole DOM
alert($( this ).text() ); == to get the whole DOM
window.myintro=data.this.intro; -- to get the intro node of DOM
alert(myintro); -- to get the intro node of DOM /code
I appreciate help to get me to understand the right syntax & logic

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Traversing DOM

Hello! Here is JQuery docs site http://api.jquery.com/jQuery/ where you can get more info. Also this should help http://api.jquery.com/category/traver...

In your example codealert($(data).text());/code
data - it's a selector (see http://api.jquery.com/category/select...)

for example codealert($("body").text());/code

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Traversing DOM

Thanks Marina. You're always a life safer! I've gone through the references you cited but I'm still having some trouble. Please be patient with me. When I did the codealert($("body").text());/code it gave me some truncated text.
What I really want to know is this: In my dayREST that you helped me with the other time, I have the root element containing the whole document, then "intro" and "days" with children. What I'm having trouble understanding is:

  1. How to reference the whole xml data
  2. How to reference the "intro" (or "days") data
  3. How to reference any of the children of the child (I think I can get this through children()
    JQuery is quite foggy to me. But if I can get a visual help like that, it would help me greatly. Thanks.
Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Traversing DOM

Could you clarify please are you going to work with DOM or service xml response (then response sample would help).

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Traversing DOM

Thanks again Marina. I didn't realize there's a difference. Yes, I am using service xml response. It's the same Daytest project you were helping me on, which has been shared. I am accessing for example the intro and then days tags to get the children under them. For example getting the intro elements to display on the introPage, etc.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Traversing DOM

Return to “Issues”