Question

Currently I have set up a button to Show Disqus Comments

I would also like to have a button to Hide the Disqus Comments after they have been loaded

My current code for the show button is:

<div id="disqus_thread"></div>
<div id="disqus_loader" class="button" style="text-align: center">
  <button onclick='$.ajaxSetup({cache:true});$.getScript("http://westonganger.disqus.com/embed.js");$.ajaxSetup({cache:false});                    
  $("#disqus_loader").remove();'>Show Comments</button>
</div>

I am just delving into javascript and jquery, so if someone could help me that would be great

Was it helpful?

Solution

Change:

$("#disqus_loader").remove();

To:

$("#disqus_loader").toggle();

This will switch between display: none and display: block. Calling remove() removes the content from the DOM completely.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top