[ACCEPTED]-Animate text size with jQuery then return to previous state-css
Accepted answer
This works and looks much better...
$(document).ready(function() {
$('.button-1,.button-2,.button-3').each(function() {
$(this).data('original-size', $(this).css('fontSize'));
$(this).click(function() {
$(this).animate({
fontSize: "40px"
}, 1000);
$(this).siblings().each(function() {
var originalSize = $(this).data('original-size');
if ($(this).css('fontSize') != originalSize) {
$(this).animate({
fontSize: originalSize
}, 500);
}
});
});
});
});
If you 5 were lazy, you could also do...
$(this).siblings().removeAttr('style')
This solution, however, is 4 flaky and could lean to painful debugging if 3 you or jQuery adds extra styles via the 2 style
attribute. I recommend you use the former 1 code.
Here's a shorter way to do it
$(document).ready(function() {
$('.button-1,.button-2,.button-3').click(function() {
$('div').removeClass('button-4', 50);
$(this).addClass('button-4', 100);
});
});
Check working 1 example at http://jsfiddle.net/nLnvY/2/
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.