ViROscar
ViROscar

Reputation: 148

Glitch with internet explorer using a textarea and CSS font-size

I have created a js (with jQuery) to change the size of the text inside a textarea by changing the css. pressing a button the next JavaScript is called:

$("#id").css("font-size",fontsize + "px");

And it's working. but with internet explorer (at least the version 9), the text goes outside the bounds of the Textarea, but if I edit the text, it automatically is arranged.

Example:

text before changing the size Text before changing the size

text after changing the size Text after changing the size. This is only happening with IE

text after edit the textarea Text after edit the textarea. This is the result that a get in Chrome, but for IE this only happen after edit it

For me, that's a glitch, is there any workaround to fix it?

Upvotes: 0

Views: 332

Answers (1)

Dhruv Ramani
Dhruv Ramani

Reputation: 2643

I think this should work for you :

var value=$("#id").value();
$("#id").css("font-size",fontsize + "px").replaceWith( $("#id").clone().val(value) );

All I am doing is re-inserting the element in the DOM. I think this is the only way to solve this annoying bug.

Happy coding!

Upvotes: 1

Related Questions