Want to rotate div 45 degree on each click. It works fine as expected. I have 3 '.expand-btn' class name in this page. What happens, on click it triggers on all '.expand-btn'.
I want to trigger only on this 'expand-btn'. not others.
JS:
var _rotation = 0;
$.fn.rotate = function(degrees) {
$(this).css({'transform' : 'rotate('+ degrees +'deg)'});
};
$('.expand-btn').click(function() {
_rotation += 45;
$(this).rotate(_rotation);
});
HTML:
<div class="expand-btn" id="test1">
<a href="javascript:void(0);" data-toggle="collapse">+</a>
</div>
<div class="expand-btn" id="test2">
<a href="javascript:void(0);" data-toggle="collapse">+</a>
</div>
<div class="expand-btn" id="test3">
<a href="javascript:void(0);" data-toggle="collapse">+</a>
</div>