Hide Div with Class Name Having Space in It Using Jquery
<div class="rcbScroll rcbWidth rcbNoWrap" style="height: 200px; width: 100%; overflow: auto"> </div>

This is my div. I want to hide the div using the class name. I am not able to do as class name as space in it. It is only one class.

1

3 Answers

Class names can not have spaces in them. So you have to think of it as 2 class names.

Eg: class="word1 word2"

Can be selected with the following:

var myVar = $('.word1.word2');

In your specific case, it becomes:

$('.rcbScroll.rcbWidth.rcbNoWrap').hide();

The spaces means multiple class names, you can use any of these classes to hide the div.

Example:

$(".rcbScroll").hide()

You can use dot to join multiple classes in selector being separated by space character.

Live Demo

$(".rcbScroll.rcbWidth.rcbNoWrap").hide();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest