RupertA
asked on
removing a class in javascript
Hi, on the css I have two classes as follows...
.list_menu a {
display: block;
padding: 12px 0px;
background: #e1e1e1;
text-decoration: none;
}
.list_menu a:hover {
background: #d4d4d4;
background-repeat:no-repea t;
width:100%;
}
I want to remove them both and add my own Selected state when you click my div, I am using the following javascript function when you click, but it doesn't work, am I referencing the classes wrongly? Thanks.
function addMySelectedState()
{
var nameElem1 = document.getElementById("o ption1");
nameElem1.classList.remove ("list_men u a");
nameElem1.classList.remove ("list_men u a:hover");
nameElem1.classList.add("l ist_menu_s elected");
}
.list_menu a {
display: block;
padding: 12px 0px;
background: #e1e1e1;
text-decoration: none;
}
.list_menu a:hover {
background: #d4d4d4;
background-repeat:no-repea
width:100%;
}
I want to remove them both and add my own Selected state when you click my div, I am using the following javascript function when you click, but it doesn't work, am I referencing the classes wrongly? Thanks.
function addMySelectedState()
{
var nameElem1 = document.getElementById("o
nameElem1.classList.remove
nameElem1.classList.remove
nameElem1.classList.add("l
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
ASKER