Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery menu with XML
    primarykey
    data
    text
    <p>To be honest I didn't still used XML with jQuery.</p> <p>I have a little XML (below):</p> <pre><code>&lt;folder title="Home"&gt; &lt;item title="Welcome" /&gt; &lt;folder title="My Photos"&gt; &lt;folder title="Holidy"&gt; &lt;item title="Photo 1" /&gt; &lt;item title="Photo 2" /&gt; &lt;item title="Photo 3" /&gt; &lt;item title="Photo 4" /&gt; &lt;item title="Photo 5" /&gt; &lt;/folder&gt; &lt;folder title="Christmas"&gt; &lt;item title="Photo 1" /&gt; &lt;item title="Photo 2" /&gt; &lt;item title="Photo 3" /&gt; &lt;item title="Photo 4" /&gt; &lt;item title="Photo 5" /&gt; &lt;item title="Photo 6" /&gt; &lt;item title="Photo 7" /&gt; &lt;item title="Photo 8" /&gt; &lt;/folder&gt; &lt;folder title="Zoo"&gt; &lt;item title="Photo 1" /&gt; &lt;item title="Photo 2" /&gt; &lt;item title="Photo 3" /&gt; &lt;item title="Photo 4" /&gt; &lt;/folder&gt; &lt;/folder&gt; &lt;folder title="My Videos"&gt; &lt;item title="Movie 1" /&gt; &lt;item title="Movie 2" /&gt; &lt;item title="Movie 3" /&gt; &lt;item title="Movie 4" /&gt; &lt;item title="Movie 5" /&gt; &lt;item title="Movie 6" /&gt; &lt;item title="Movie 7" /&gt; &lt;item title="Movie 8" /&gt; &lt;/folder&gt; &lt;folder title="My Audio"&gt; &lt;folder title="Artist 1"&gt; &lt;folder title="Album 1"&gt; &lt;item title="Track 1" /&gt; &lt;item title="Track 2" /&gt; &lt;item title="Track 3" /&gt; &lt;item title="Track 4" /&gt; &lt;item title="Track 5" /&gt; &lt;item title="Track 6" /&gt; &lt;item title="Track 7" /&gt; &lt;/folder&gt; &lt;folder title="Album 2"&gt; &lt;item title="Track 1" /&gt; &lt;item title="Track 2" /&gt; &lt;item title="Track 3" /&gt; &lt;item title="Track 4" /&gt; &lt;item title="Track 5" /&gt; &lt;item title="Track 6" /&gt; &lt;item title="Track 7" /&gt; &lt;item title="Track 8" /&gt; &lt;/folder&gt; &lt;/folder&gt; &lt;folder title="Artist 2"&gt; &lt;folder title="Album 1"&gt; &lt;item title="Track 1" /&gt; &lt;item title="Track 2" /&gt; &lt;item title="Track 3" /&gt; &lt;item title="Track 4" /&gt; &lt;item title="Track 5" /&gt; &lt;item title="Track 6" /&gt; &lt;item title="Track 7" /&gt; &lt;/folder&gt; &lt;/folder&gt; &lt;folder title="Podcasts"&gt; &lt;item title="Track 1" /&gt; &lt;item title="Track 2" /&gt; &lt;item title="Track 3" /&gt; &lt;item title="Track 4" /&gt; &lt;item title="Track 5" /&gt; &lt;item title="Track 6" /&gt; &lt;item title="Track 7" /&gt; &lt;item title="Track 8" /&gt; &lt;/folder&gt; &lt;/folder&gt; &lt;/folder&gt; </code></pre> <p>and I want to populate the html in this order (below):</p> <pre><code>&lt;div class="entry"&gt; &lt;p&gt;&lt;span class="links"&gt;Sub-directory&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="files"&gt;File One&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="files"&gt;File Two&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="files"&gt;File Three&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;spanclass="files"&gt;FileFour&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;spanclass="files"&gt;FileFive&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="files"&gt;File Six&lt;/span&gt;&lt;/p&gt; &lt;/div&gt; </code></pre> <p>and I want to navigate inside... I have understand how to load the XML but I didn't understand how to put inside the span TAG the title text. And when naveigate into "My Photos"... how to see the child contents...</p> <p>Thanks in advance for the help.</p> <p>EDIT:</p> <p>Here the jQuery (below):</p> <pre><code>$.ajax({ type: "GET", url: "content.xml", dataType: "xml", success: function (xml) { $(xml).find('Home').children().each(function () { var title_text = $(this).attr('title'); var spanFiles = $('span.files'); spanFiles .html(title_text) .appendTo('div.entry'); }); } }); </code></pre> <p>but doesn't work...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload