Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add class for h4 tag which is in second li - jquery
    text
    copied!<p><strong>EDIT</strong>: Added UL class</p> <pre><code> &lt;ul class="expand-coll-list"&gt; &lt;li&gt; &lt;h4 class="title-exp-coll title-expand"&gt; &lt;span class="exp-coll"&gt;&lt;/span&gt;Bookmarks&lt;/h4&gt; &lt;div class="item-list"&gt; &lt;ul&gt; &lt;li class="first"&gt;&lt;div&gt;first Asset&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div&gt;Latest Updates&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div&gt;asset image&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div&gt;test Asset 1&lt;/div&gt;&lt;/li&gt; &lt;/ul&gt;&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;h4 class="title-exp-coll title-expand"&gt; &lt;span class="exp-coll"&gt;&lt;/span&gt;Menu&lt;/h4&gt; &lt;p&gt;No menu.&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>For example if i load content/page1</p> <p>I need to <strong>remove class titl-expand and add class title-collapse</strong> in the <strong>h4 tag</strong> which is in <strong>first li</strong></p> <p>For example if i load content/page2</p> <p>I need to do the same function for page1 in the h4 tag which is in <strong>second li</strong></p> <p>My Code:</p> <p>Which works for first case but not for second...</p> <pre><code>if(arg[1] == 'content' &amp;&amp; arg[2] == 'page1') { $(".expand-coll-list li:first").children("h4").removeClass("title-collapse").addClass("title-expand"); } else if(arg[1] == 'content' &amp;&amp; arg[2] == 'page2') { $(".expand-coll-list li:eq(1)").children("h4").removeClass("title-collapse").addClass("title-expand"); } </code></pre> <p>What is wrong with it?</p> <p>Thanks in advance..</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