Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, you should use the jQuery <code>addClass()</code> method. You don't need to write your own (your addClass() implementation is buggy, by the way).</p> <p>Try this:</p> <pre><code>function selectInList(obj) { $("#circularMenu").children("a").removeClass("highlight"); $(obj).addClass("highlight"); } </code></pre> <p>Then:</p> <pre><code> &lt;ul id="circularMenu"&gt; &lt;a href="#strategy" onclick="selectInList(this);"&gt;&lt;li id="strategy_link"&gt;&lt;h3&gt;Strategy&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;a href="#branding"&gt;&lt;li id="branding_link" onclick="selectInList(this);"&gt;&lt;h3&gt;Branding&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;a href="#marketing"&gt;&lt;li id="marketing_link" onclick="selectInList(this);"&gt;&lt;h3&gt;Marketing&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;a href="#media"&gt;&lt;li id="media_link" onclick="selectInList(this);"&gt;&lt;h3&gt;Media&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;a href="#management"&gt; &lt;li id="management_link" onclick="selectInList(this);"&gt;&lt;h3&gt;Management&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;/ul&gt; </code></pre> <p>Or even better, keep your html clean and let jQuery simplify things:</p> <pre><code> &lt;ul id="circularMenu"&gt; &lt;a href="#strategy"&gt;&lt;li id="strategy_link"&gt;&lt;h3&gt;Strategy&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;a href="#branding"&gt;&lt;li id="branding_link"&gt;&lt;h3&gt;Branding&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;a href="#marketing"&gt;&lt;li id="marketing_link"&gt;&lt;h3&gt;Marketing&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;a href="#media"&gt;&lt;li id="media_link"&gt;&lt;h3&gt;Media&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;a href="#management"&gt;&lt;li id="management_link"&gt;&lt;h3&gt;Management&lt;/h3&gt;&lt;/li&gt;&lt;/a&gt; &lt;/ul&gt; </code></pre> <p>Then, somewhere in your page:</p> <pre><code>$(document).ready(function() { $("#circularMenu").children("a").click(function() { selectInList(this) }); }); </code></pre>
 

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