Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy the javascript toggle code doesn't work?
    text
    copied!<p>I have added the <strong>Prototype</strong> library to my site, then add the following code. but when i click the span, the ul content is not hidden. the link href still work.</p> <pre><code>Event.observe(window, 'load', function() { Event.observe('.block-category li.parent span', 'click', function(e){ $('.block-category li.parent ul').toggle(); e.preventDefault(); }); }); </code></pre> <p>html:</p> <pre><code> &lt;div class="block block-category"&gt; &lt;li class="level-top parent"&gt; &lt;a href="example.com/...."&gt;&lt;span&gt;text one&lt;/span&gt;&lt;/a&gt; &lt;ul&gt; //the 1 ul &lt;li&gt;&lt;a&gt;&lt;span&gt;....&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;span&gt;....&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;span&gt;....&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;span&gt;....&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="level-top"&gt;&lt;a href="..."&gt;&lt;span&gt;....&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="level-top parent"&gt; &lt;a href="example.com/...."&gt;&lt;span&gt;text two&lt;/span&gt;&lt;/a&gt; &lt;ul&gt; //the 2 ul &lt;li&gt;&lt;a&gt;&lt;span&gt;....&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="level-top parent"&gt; &lt;a href="example.com/...."&gt;&lt;span&gt;text three&lt;/span&gt;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a&gt;&lt;span&gt;....&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;span&gt;....&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/div&gt; </code></pre> <p>thank you.</p> <p><strong>ps</strong>: when click <strong>text one</strong>, the the 1 ul toggle. when click *<em>text two</em>*the 2 ul toggle, ...</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