As someone who is relatively new to JQuery and web development, I find myself in need of assistance. Despite researching for a few days, I have not been able to find a solution that meets my requirements. While browsing through various forums, I noticed that similar questions have been asked numerous times, but most of the answers provided are outdated given the current release of JQuery.
The issue at hand is that I have a 'div' element that I want to be centered on the screen when clicked. This functionality is working as expected. However, I am struggling to make the same 'div' return to its original position when clicked for the second time.
$(document).on("page:change", function() {
$("#profile").on ("click", function() {
$("#profile").animate({right: '15%', height: '+=50px', width: '+=25%'});
$("#profile").css("position", "absolute"); // To maintain normal position within bootstrap grid during animation
$("#fadeback").css("opacity", 0.6).fadeIn(300); // Fades other elements on the page
});
});
I am primarily looking for a way to revert these operations upon a second click. If you have an alternative approach that differs from my current implementation, I am open to exploring it. Thank you in advance for your assistance!