Last active
August 9, 2019 05:56
-
-
Save harapeko/ec50117dfabfb7fc4412b912de3b7c56 to your computer and use it in GitHub Desktop.
対象先をトグルクラスするjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SEE: https://codepen.io/harapeko/pen/KWobXR | |
class ToggleTarget | |
init: => | |
$(document).off 'click' | |
$(document).on 'click', '.js-toggle', (event)-> | |
event.preventDefault() | |
$btn = $ @ #clickした要素 | |
$(document).off 'click', '.js-toggle' | |
$target = if $btn.data 'toggle-class' then $btn.data 'toggle-class' else '-active' | |
$("##{$target}").toggleClass $class | |
$ => | |
toggle = new ToggleTarget | |
toggle.init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment