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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -