javascript - How to toggle style in animation using jQuery? -


how can add opacity: 0.5 li when it's clicked , toggle opacity opacity:1 when clicked again animation?

$('li').on('click', function () {     $(this).animate({         opacity: 0.5     }, 500, function () {         $(this).toggleclass('completed');     }); }); 

is there simple solution toggling between classes or need add logic check current opacity , change accordingly? don't want change markup or css through jquery.

we can use math :)

$('li').on('click', function () {     $(this).animate({         opacity: (0.5 / $(this).css("opacity"))     }, 500, function () {         $(this).toggleclass('completed');     }); }); 

Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -