Skip to content

Instantly share code, notes, and snippets.

@dogrunjp
Created May 4, 2014 08:39
Show Gist options
  • Save dogrunjp/11512915 to your computer and use it in GitHub Desktop.
Save dogrunjp/11512915 to your computer and use it in GitHub Desktop.
jQueryで隣の要素をtoggleしつつトリガーのアイコンのイメージをtoggleに合わせ交互に変更する方法。 (Font Awsomeアイコンを使う場合)
$(".switch").click(function(){
$(this).next().slideToggle();
$("span",this).toggleClass("fa-mimus-square");
$("span",this).toggleClass("fa-plus-square");
})
<div class="switch">
<span class="fa fa-mimus-square"></span>
</div>
<div>..</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment