Call a class with a class in Javascript
This question already has an answer here:
You have to connect them. The proper selector would be:
$('.about_us.aperto')
如果你想选择一个具有多个类的元素,比如<div class="classA classB ClassC"></div>
那么只需在JavaScript中加入它们即可,例如$('.classA.classB.classC').click(function() {...});
$('.about_us.aperto').click(function() {
$(this).toggleClass('active');
});
.active {
background: #0f0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="about_us aperto">
<p>Lorem ipsum dolor sit amet</p>
</div>
链接地址: http://www.djcxy.com/p/83106.html
上一篇: 按类别查找对象并淡入另一个对象
下一篇: 用Javascript中的类调用一个类