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

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -