Assuming I have
how can I change the value of verticalList using jquery?
There are several functions that you can use to manipulate an element class.
toggleClass
adds a class on the element if it doesn't exists. If it exists then it's removed.
$(".myList").toggleClass("verticleList");
addClass
insert the class on the element. If the class already exists it does nothing.
$(".myList").addClass("aClass");
removeClass
remove the class from the element. If the class doesn't exists it does nothing.
$(".myList").removeClass("aClass");
hasClass
returns true
or false
if the element has or not a class.
$(".myList").hasClass("aClass");
You can also change the class modifying the attribute (.attr
) class
which may not be recommended.