Q
How can you remove a CSS class from an HTML element using JavaScript?

Answer & Solution

Answer: Option A
Solution:
To remove a CSS class from an HTML element using JavaScript, you can use the element.classList.remove('className') method. This method removes the specified CSS class ('className') from the element, effectively removing associated styles or behavior from the element in the document.
Related Questions on Average

Which JavaScript method allows you to change the value of an HTML attribute?

A). setAttribute()

B). getAttribute()

C). removeAttribute()

D). createElement()

How can you set the text alignment of an HTML element using JavaScript?

A). element.style.textAlign = 'alignment';

B). element.style.align = 'alignment';

C). element.textAlign = 'alignment';

D). element.align = 'alignment';

How can you set the background color of an HTML element using JavaScript?

A). element.style.backgroundColor = 'color';

B). element.style.background = 'color';

C). element.background = 'color';

D). element.style.color = 'color';

How can you set the font size of an HTML element using JavaScript?

A). element.style.fontSize = 'size';

B). element.style.fontsize = 'size';

C). element.fontsize = 'size';

D). element.size = 'size';

How can you enable a disabled HTML button using JavaScript?

A). element.disabled = false;

B). element.removeAttribute('disabled');

C). element.enable();

D). element.enable = true;

How can you set the font color of an HTML element using JavaScript?

A). element.style.color = 'color';

B). element.style.fontColor = 'color';

C). element.fontColor = 'color';

D). element.color = 'color';

How can you add a CSS class to an HTML element using JavaScript?

A). element.classList.add('className');

B). element.className = 'className';

C). element.setAttribute('class', 'className');

D). element.addClass('className');

How can you change the href attribute of an anchor (link) element using JavaScript?

A). element.href = 'https://example.com';

B). element.setAttribute('href', 'https://example.com');

C). element.setHref('https://example.com');

D). element.changeHref('https://example.com');

How can you set the border width of an HTML element using JavaScript?

A). element.style.borderWidth = 'width';

B). element.style.border.width = 'width';

C). element.border.width = 'width';

D). element.width = 'width';

How can you dynamically change the source (URL) of an image element using JavaScript?

A). element.src = 'newimage.jpg';

B). element.setSource('newimage.jpg');

C). element.setAttribute('src', 'newimage.jpg');

D). element.changeSource('newimage.jpg');