I am changing the class of an element with the following
$(\"#\"+data.id).addClass(\"highlight\")
Given the list below.
<
You need to select the li
tags contained within the .edgetoedge
class. .edgetoedge
only matches the one ul
tag:
$(".edgetoedge li").removeClass("highlight");
The best to remove a class in jquery from all the elements is to target via element tag. e.g.,
$("div").removeClass("highlight");
This just removes the highlight
class from everything that has the edgetoedge
class:
$(".edgetoedge").removeClass("highlight");
I think you want this:
$(".edgetoedge .highlight").removeClass("highlight");
The .edgetoedge .highlight
selector will choose everything that is a child of something with the edgetoedge
class and has the highlight
class.
$(".edgetoedge>li").removeClass("highlight");
You could try this:
$(".edgetoedge").children().removeClass("highlight");
try: $(".highlight").removeClass("highlight");
. By selecting $(".edgetoedge")
you are only running functions at that level.