0

This is probably a silly question.

I have this class

<div class="about_us aperto">

how do I call it in a JS function? I'm trying:

$('.about_us aperto').click(function(){...
$('.about_us .aperto').click(function(){...

but they do not work.

Federico
  • 1,392
  • 1
  • 17
  • 40
  • you can do it like this `$('.about_us.aperto').click(function(){...` , remove the spaces in between – Rashid May 23 '16 at 07:54

2 Answers2

2

You have to connect them. The proper selector would be:

$('.about_us.aperto')
Joe Thomas
  • 5,807
  • 6
  • 25
  • 36
0

If you wants to select an element having multiple classes like <div class="classA classB ClassC"></div> then just join them together in JavaScript i.e. $('.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>
Mohammad Usman
  • 37,952
  • 20
  • 92
  • 95