javascript - How can I find the width and height of a specific word within a string? -
i'm trying replace specific class-less word, not entire string, form of same height (or font-size) , width. want work if change css. here code:
var magicword = "abracadabra"; var width = $('#words').width(); var height = $('#words').height(); var x = width + "px"; var y = height + "px"; $('html').append("<form><input type='text' style='width: "+x+"; height: "+y+"; font-family: courier;'></form>")
here updated fiddlicious. figured out myself using replace(). more efficient awarded coveted green check mark.
you have have dom identifier word. can change :-
<span id ="words">here bunch of <span> abracadabra </span> </span>
and javascript
var magicword = "abracadabra"; var width = $('#words span').width(); var height = $('#words span').height(); var x = width + "px"; var y = height + "px" $('html').append("<form><input type='text' style='width: "+x+"; height: "+y+"; font- family: courier;'></form>")
Comments
Post a Comment