jQuery 使用jquery隐藏带有空格的类名的div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15698360/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide div with class name having space in it using jquery
提问by Somnath Kharat
<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.
这是我的 div。我想使用类名隐藏 div。我不能像其中的空间那样做类名。它只有一个班级。
回答by Hugo Dozois
Class names can not have spaces in them. So you have to think of it as 2 class names.
类名中不能有空格。因此,您必须将其视为 2 个类名。
Eg: class="word1 word2"
例如: class="word1 word2"
Can be selected with the following:
可以通过以下方式选择:
var myVar = $('.word1.word2');
In your specific case, it becomes:
在您的特定情况下,它变为:
$('.rcbScroll.rcbWidth.rcbNoWrap').hide();
回答by ATOzTOA
The spaces means multiple class names, you can use any of these classes to hide the div
.
空格表示多个类名,您可以使用这些类中的任何一个来隐藏div
.
Example:
例子:
$(".rcbScroll").hide()