문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top