Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery showing related xml categories
    primarykey
    data
    text
    <p>I have an xml file like this:</p> <pre><code>&lt;?xml version="1.0" ?&gt; &lt;scketchit&gt; &lt;categories&gt; &lt;category title="MANGA" /&gt; &lt;category title="MARVEL" /&gt; &lt;/categories&gt; &lt;comics&gt; &lt;comic title="Comic number 1"&gt; &lt;date&gt;21/02/2011&lt;/date&gt; &lt;category&gt;MANGA&lt;/category&gt; &lt;/comic&gt; &lt;comic title="Comic number 2"&gt; &lt;date&gt;13/02/2011&lt;/date&gt; &lt;category&gt;MARVEL&lt;/category&gt; &lt;/comic&gt; &lt;comic title="Comic number 4"&gt; &lt;date&gt;12/02/2011&lt;/date&gt; &lt;category&gt;MANGA&lt;/category&gt; &lt;/comic&gt; &lt;/comics&gt; &lt;/scketchit&gt; </code></pre> <p>and i want to convert the categories items into links and when i click in this categories show in a div the corresponding comics I'm new to jquery and this is the jquery i'm writting:</p> <pre><code> $(document).ready(function(){ $.ajax({ type: "GET", url: "comics.xml", dataType: "xml", success: xmlParser }); }); function xmlParser(xml) { $(xml).find('categories').eq(0).find('category').each(function () { $("#categories-data1").append('&lt;div class="title"&gt;&lt;a href="#" class="CategoryTab"&gt;' + $(this).attr('title') + '&lt;/a&gt;&lt;/div&gt;'); }); var nav_link = $('.CategoryTab'); nav_link.click( function() { alert( $(xml).find("category:contains('" + nav_link.html() + "')").closest('comic').html() ); }); } </code></pre> <p>I don't know if iwhat i'm doing is well done and i cant show the comic items for every category.</p> <p>How would you do all this?</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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