在jQuery中使用两个类调用div
我有一个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 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)代码>