smoothley animate a span to fit its text with jquery -


i have created hangman game each letter in span.

html

<span class="letter">a</span> 

css

.letter{     height:40px;     width:40px;     line-height:40px;     text-align:center; } 

after puzzle solved want move letters beside each other form word, need resize span fit text (that 1 letter) avoid spaces. removing class contains height , width results need problem want smoothly.

clone element, set clone width auto , measure width. remove it, , animate original width.

something this:

$('span.letter').each(function(){     var temp = $(this).clone();     $('body').append(temp);     temp.css('width', 'auto');     var newwidth = temp.width();     temp.remove();     $(this).animate('width', newwidth); }); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -