jquery - How to use a class name stored as a data-* attribute as a selector -
i'm working small click function want store data in html5 attribute, i'm stumped how use class name stored selector run function on. here's html stored classname:
<a href="#" data-toggle=".calendar__event--blue">click</a>
when element clicked, want hide '.calendar__event--blue' class. here's i've tried:
$('.sidebar__mycals--nested a').on('click', function () { var eltoggle = $(this).data('toggle') eltoggle.fadeout() })
but returning data object instead of class name selector, wondering if there's way target element data store. thanks!
you mean like:
$('.sidebar__mycals--nested a').on('click', function () { var eltoggle = $(this).data('toggle'); $("."+eltoggle).fadeout(); })
Comments
Post a Comment