I’ve an text input. I want to change font size on focus, and get the old value on blur. For example default is 14 and 10 when focused. But when I do this, the size of whole input is changing. How to avoid that?
UPDATE:
The task isn’t so easy. What if I don’t know the old width and height? I failed to obtain them using JQuery.
You can assignwidthandheightstyle properties to theinputelement, e.g.:Just be sure to use
pxand notem. 🙂Live example – Works in IE6 (!), Firefox 9, and Chrome 15, which suggests a fair degree of compatibility.
Update for edited question:
Same principal, but if you want to query the width and height and now that you’ve told us you’re using jQuery:
CSS:
JavaScript:
Live example – As with the one above, works in IE6, Firefox 9, and Chrome 15.