Skip to content

Instantly share code, notes, and snippets.

@hoksea
Last active July 26, 2019 02:27
Show Gist options
  • Save hoksea/62e4cfbc2e99d3e42b36e8978c000604 to your computer and use it in GitHub Desktop.
Save hoksea/62e4cfbc2e99d3e42b36e8978c000604 to your computer and use it in GitHub Desktop.
jQuery-slideToggle
W3SCHOOL: jQuery slideToggle() Method
https://www.w3schools.com/jquery/eff_slidetoggle.asp
StackOverflow: slideToggle the next element
https://stackoverflow.com/questions/15272381/slidetoggle-the-next-element
<!-- example. use class "hideslide" & "hidecontent"-->
<div class="hideslide" style="cursor: pointer;">點我展開/隱藏 (方法五) 例子1</div>
<div class="hidecontent" style="display:none;">
哎呀被發現了啦 (つд⊂)
(方法五) 例子1
</div>
<div class="hideslide" style="cursor: pointer;;">點我展開/隱藏 (方法五) 例子2</div>
<div class="hidecontent" style="display:none;">
哎呀被發現了啦 (つд⊂)
(方法五) 例子2
</div>
$(".hideslide").click(function(){
$(this).next(".hidecontent").slideToggle();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment