Linked Questions
15 questions linked to/from Is there a way to add/remove several classes in one single instruction with classList?
1
vote
1
answer
4k
views
Can I add a class with spaces to an element? [duplicate]
I am trying to add a fontawesome.com icon class ("fa fa-arrow-right")to a span in my website site but since it contains spaces I get an error. What can I do to fix this?
This is the error I ...
1
vote
1
answer
3k
views
Javascript change a button class onclick using "classList" [duplicate]
I want to change the appearance of two buttons when either one of them is clicked. But I cannot seem to do that.
I want the classes of the buttons to be changed every time a new button is clicked, ...
0
votes
2
answers
1k
views
Javascript adding multiple css selectors using a function and classList [duplicate]
I'm trying to add multiple css selectors to an element using classList that's inside a function, but keep getting the below error. How do I do this right?
Uncaught DOMException: Failed to execute 'add'...
0
votes
1
answer
757
views
Could I use variable in this.classList.remove [duplicate]
I try to use this code in my javascript program:
this.classList.remove(RF.DangerClass);
Where RF.DangerClass is global variable.
But I get error -
InvalidCharacterError: String contains an ...
1
vote
1
answer
128
views
animation on mouseover event doesn't work [duplicate]
document.getElementById("both-gif").onmouseover=function() {MouseOver()};
document.getElementById("both-gif").onmouseout=function() {MouseOut()};
function MouseOver() {
document.getElementById("...
0
votes
3
answers
69
views
Addition classes to each boxes from array in object (JS) [duplicate]
I want to add classes named like those in data array (categories) to each boxes in sequence (in container).
For example, first box except "box" class should have: "highlighted" "special-header" "...
0
votes
0
answers
69
views
How to remove the same class from multiple elements? [duplicate]
Is there a way to remove the same div class from two separate divs?
I have a one-page application and I'm trying to get two of my divs that live in the same tab to hide after you click the other nav ...
1
vote
1
answer
68
views
jQuery .click() event not working. Out of two one is working the other does not [duplicate]
$('.like-btn').click((e) => {
e.target.classList = 'like-unlike-btn unlike-btn far fa-heart';
});
$('.unlike-btn').click((e) => {
e.target.classList = 'like-unlike-btn like-btn far fa-heart'...
0
votes
0
answers
37
views
Issues with JavaScript list [duplicate]
I am assigned to create this to do list using eventlisteners and using JavaScript. My HTML and CSS are given to me however I believe I may be confusing my Id's with each other. The expectation is ...
0
votes
0
answers
33
views
Can I use Javascript to change page styling? [duplicate]
I have tried searching this but it seems that it's not common for a site to only allow for JS injection vs CSS.
I have done some CSS coding on my other WordPress sites successfully but just switched ...
0
votes
0
answers
243
views
how to remove multiple class using variable
i've got snippet for this
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("Text", ev.target.id);
ev.dataTransfer.setData("class", ev....
0
votes
3
answers
101
views
How to manipulate css using javascript?
I was trying to manipulate the css when clicking on button using javascript . I want to just make a single button active the one which is recently clicked.
I am able to make it active but somehow i am ...
2
votes
2
answers
102
views
jQuery inside an event using classList
When I press a <button>, I want to wait for an asynchronous function, then add some classes to the <button>, but it doesn't work. I want to use jQuery to do this.
Here is my code:
$("#...
-3
votes
2
answers
79
views
Classlist.add in a shorter way?
Hey I have to give some list items their own classes. But my way of doing it is a bit too much. Is there a way to make this cleaner with a loop or something like that?
Javascript:
function ...
-1
votes
2
answers
50
views
javascript not adding class to div
<div
id="overlay_block"
class="overlay-type overlay"
data-text-placement="{{ block.settings.overlay_position }}"
data-mobile-text-placement="{{ block....