New filters on the Home Feed, take a look!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
Having difficulty to add a class to a tag
Post Body

I am trying to add a class to a tag html via jquery but something is going wrong I get the element but it's not adding the class I don't get what I am missing:

//HTMl

<ul class="cm-nav-list">

<li class="cm-nav-list\\\_\\\_item cm-nav-list\\\_\\\_item--item1 is-active">

<span class="span1">Label1</span>

<span class="span2">Label2</span>

</li>

<li class="cm-nav-list\\\_\\\_item cm-nav-list\\\_\\\_item--item2">

<span class="span1">Label1</span>

<span class="span2">Label2</span>

</li>

<li class="cm-nav-list\\\_\\\_item cm-nav-list\\\_\\\_item--item3">

<span class="span1">Label1</span>

<span class="span2">Label2</span>

</li>

<li class="cm-nav-list\\\_\\\_item cm-nav-list\\\_\\\_item--item4">

<span class="span1">Label1</span>

<span class="span2">Label2</span>

</li>

<li class="cm-nav-list\\\_\\\_item cm-nav-list\\\_\\\_item--item5">

<span class="span1">Label1</span>

<span class="span2">Label2</span>

</li>

<li class="cm-nav-list\\\_\\\_item cm-nav-list\\\_\\\_item--item6">

<span class="span1">Label1</span>

<span class="span2">Label2</span>

</li>

</ul>

//JS

function selectSquare() {

var me = $(this);

meIndex = me.index();

var selectedItem = me.eq(meIndex);

console.log(selectedItem);

selectedItem.addClass("is-active");

}

function init() {

var label = $(".cm-nav-list__item");

label.click(selectSquare);

}

$(document).ready(init);

Author
Account Strength
80%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
248
Link Karma
96
Comment Karma
152
Profile updated: 4 days ago
Posts updated: 1 month ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 years ago