Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在jQuery中使用两个类调用div_Jquery_Css_Class - Fatal编程技术网

在jQuery中使用两个类调用div

在jQuery中使用两个类调用div,jquery,css,class,Jquery,Css,Class,我有一个div,有两个类: <div class="content pager" style="width: 1156px; float: left; list-style: none outside none;"></div> 但它不起作用。有什么问题吗?试试这个: $(".content.pager").width(0); $(".content").filter(".pager").width(0); 选中 width(0)不会隐藏其内容。您需要隐藏它。而不是

我有一个div,有两个类:

<div class="content pager" style="width: 1156px; float: left; list-style: none outside none;"></div>
但它不起作用。有什么问题吗?

试试这个:

$(".content.pager").width(0);
$(".content").filter(".pager").width(0);
选中

width(0)
不会隐藏其内容。您需要
隐藏它。而不是宽度(0)
。因此,您可以尝试以下方法:

$(".content.pager").hide(0); // Will hide the div and free its space.
$(".content.pager").css('visibility', 'hidden'); // Will hide the div and take space belongs to it.
试试这个:

$(".content.pager").width(0);
$(".content").filter(".pager").width(0);

另一种选择是jQuery的方法。基本上,您搜索一个类,然后按另一个类过滤所选内容。但是,对于您的特殊需求,$(“.class1.class2”)应该足够了。过滤器示例:

<div class="foo bar">div1</div>
<div class="foo">div2</div>
<div class="bar">div3</div>
​
$(".foo").filter(".bar").css('background-color', 'red');​
div1
第二组
第三组
​
$(“.foo”).filter(“.bar”).css('background-color','red');​

请参阅。

可能重复的@Rorshak。您应该像使用
$(“.content.pager”)。宽度(0)