Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery accessing distanced parents
    text
    copied!<p>Consider the following HTML structure for drop-down menu: </p> <pre><code>&lt;ul class="tabMenu"&gt; &lt;li&gt;&lt;a href="#"&gt;Games&lt;/a&gt; &lt;div id="sub"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Main&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;3D&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Videos&lt;/a&gt; &lt;div id="sub"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Main&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;3D&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Under this menu I write some string using Jquery(Home is the default value) which tells the user where he is:</p> <pre><code>&lt;div class="Pointer"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/div&gt; </code></pre> <p>The following Jquery is used for detecting which category/subcategory is trigerred:</p> <pre><code>$('.tabMenu li a').click(function() { //get current link var currentLink = $(this); //get link text var linkText = currentLink.text(); //Remove all activeTab classes $('.activeTab').removeClass('activeTab'); //Add selected class with activeTab currentLink.parent().addClass("activeTab"); //Change pointer value according to the click $('.Pointer a').html(linkText); }); </code></pre> <p>The Jquery function should return string which looks like Videos->Main if the user clicks subcategory 'Main' from the drop-down on 'Videos' and Games->Main if the user chooses Main from Games. This code gives only Main no matter if it was clicked from 'Games' or 'Videos' Any help will be greatly appreciated.</p>
 

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