jQuery animate width on button text change -


if have button default css, how can make when click button, text changes , it's width animated fit in new text?

html

<button>click me</button> 

jquery

$(document).on("click", "button", function(){      $(this).text("you have clicked me!", function(){         $(this).animate({width:"auto"}, 1000);     });  }) 

jsfiddle

http://jsfiddle.net/hyzba/41/

you cannot animate width/height auto,

instead give invisible similar element width/height auto , saves calculated value, animate own element calculated value.

here link explain how it.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -