JavaScript Simple jQuery div toggle not working simple jquery toggle,simple jquery toggle accordion,simple jquery toggle

I'm new to JavaScript, and I'm trying to create a simple hide and show div toggle, though it's not working. I'm not sure what the issue is -- I have the div initially display:none, then when the course-info-toggle class is clicked, it should turn to display:block, and transition down.

Any ideas?

/* Toggle on course detail sections */
$(document).ready(function() {
  $('.course-info-toggle').click(function() {
    $('.toggle-content').toggleClass('.show');
  });
});
.toggle-content.show {
  display: block;
  transition: left 0.3s linear;
}

.toggle-content {
  display: none;
  background-color: #eeeeee;
  padding: 1rem;
  margin-right: 1rem;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="toggle-wrap">
  <div class="course-info-toggle">
    <p id="course-details-toggle-font">COURSE OBJECTIVES</p>
    <img src="img/course-down-arrow.png" align="course-down-arrow">
  </div>
  <div class="toggle-content">
    <p> simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled”<br>
      <p> simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled”<br>
      </p>
  </div>
</div>
Answer:1

You need to change .show to only show & add !important to display:block

/* Toggle on course detail sections */
$(document).ready(function() {
  $('.course-info-toggle').click(function() {

    $('.toggle-content').toggleClass('show');
  });
});
.toggle-content.show {
  display: block !important;
  transition: left 0.3s linear;
}

.toggle-content {
  display: none;
  background-color: #eeeeee;
  padding: 1rem;
  margin-right: 1rem;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="toggle-wrap">
  <div class="course-info-toggle">
    <p id="course-details-toggle-font">COURSE OBJECTIVES</p>
    <img src="img/course-down-arrow.png" align="course-down-arrow">
  </div>
  <div class="toggle-content">
    <p> simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled”<br>
      <p> simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled”<br>
      </p>
  </div>
</div>
Answer:2

Change this line

$('.toggle-content').toggleClass('.show');

to line

$('.toggle-content').toggleClass('show');
Answer:3

$(document).ready(function() {
	$('.course-info-toggle').click(function() {
		$('.toggle-content').toggleClass('show');
	});
});
.toggle-content.show {
	display: block;
    transition: left 0.3s linear;
}

.toggle-content {
	display: none;
	background-color: #eeeeee;
	padding: 1rem;
	margin-right:1rem;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="toggle-wrap">
	<div class="course-info-toggle">
		<p id="course-details-toggle-font">COURSE OBJECTIVES</p>
		<img src="img/course-down-arrow.png" align="course-down-arrow">
	</div>
	<div class="toggle-content">
		<p>simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled”<br>
		<p>simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled”<br>
		</p>
	</div>                          
</div>
Answer:4

toggleClass accepts a string so please use the following:

.toggleClass('show');
Answer:5

It is working as it should, unless i am mistaken and this is not a typo

$('.toggle-content').toggleClass('.show');

You should not be using '.show' it should be

$('.toggle-content').toggleClass('show');

You dont have to use .class name as per docs . It is working properly IMHO if you do this.

you can check out the fiddle here . Didnt make any changes except the one mentioned above.

Answer:6

As the title says really! You can make rspec print passing tests, instead of just any failing ones; is there a way to make Protractor do the same?

As the title says really! You can make rspec print passing tests, instead of just any failing ones; is there a way to make Protractor do the same?

I am loading an image export of my chart after the animation is complete, using the onComplete callback. My problem is that everytime you hover over the diagram, the onComplete callback is executed an ...

I am loading an image export of my chart after the animation is complete, using the onComplete callback. My problem is that everytime you hover over the diagram, the onComplete callback is executed an ...

  1. chart js animation oncomplete
  2. animation oncomplete chartjs

I'm trying to display a list inside a list. This loop works in JavaScript. for ( i=0; self.InsuredCommoditiesList.length > i; i++){ self.CommoditiesCategories = self.InsuredCommoditiesList[...

I'm trying to display a list inside a list. This loop works in JavaScript. for ( i=0; self.InsuredCommoditiesList.length > i; i++){ self.CommoditiesCategories = self.InsuredCommoditiesList[...

I'm trying to understand the following pieces of code. If I understand correctly, below I have three resource objects that interact with REST server data sources (these objects are CategorySrv, ...

I'm trying to understand the following pieces of code. If I understand correctly, below I have three resource objects that interact with REST server data sources (these objects are CategorySrv, ...