Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery selector not working properly on my multilevel navigation bar
    primarykey
    data
    text
    <p>I'm trying to make a simple horizontal navigation bar with multiple levels (but for now, I've only made a navigation bar with one sublevel). I'm following this tutorial <a href="http://www.webdesigndev.com/web-development/create-the-fanciest-dropdown-menu-you-ever-saw" rel="nofollow">here</a> with some modifications:</p> <pre><code>&lt;ul id = "sample2"&gt; &lt;li&gt; &lt;a href="#"&gt;About Us&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Website&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Creator&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt;Our Products&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Product 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Product 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Just give us money&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt;FAQs&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;What is this?&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Why should I care???&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt;Contact&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Telephone&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Mobile Phone&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;E-mail&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Login&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I used only one id on the main <code>&lt;ul&gt;</code> and I'm accessing the sublevels using <code>#sample2 ul</code> instead of using classes on those.</p> <p>However, it simply doesn't work when I use the JQuery codes:</p> <pre><code>$(function () { $('#sample2 ul').each(function () { $(this).parent().eq(0).hover(function () { $('#sample2 ul:eq(0)', this).show(100); }, function () { $('#sample2 ul:eq(0)', this).hide(100); }); }); }); </code></pre> <p>Again, I only changed the tutorial's <code>.dropdown</code> class to <code>#sample2 ul</code>.</p> <p>But it does work if I do the same way as the tutorial (i.e. assign either an id or a class on the sublevels), although I think it's unnecessary since those sub-<code>&lt;ul&gt;</code>-s can be selected using css selectors.</p> <p>What am I doing wrong? Are those sublevels really can only be selected using assigned classes/id on them?</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.
 

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