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.

1
  • you can do it like this $('.about_us.aperto').click(function(){... , remove the spaces in between Commented May 23, 2016 at 7:54

2 Answers 2

2

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

$('.about_us.aperto')
Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.