I need to re-calculate the size of an INPUT TEXT element because it will dynamically add a 20-pixel button next to it.
I tried this and it did not work
$(this).width(function () { $(this).width() - 20 });
I need to re-calculate the size of an INPUT TEXT element because it will dynamically add a 20-pixel button next to it.
I tried this and it did not work
$(this).width(function () { $(this).width() - 20 });
The .width()
method is a getter, it will only fetch the value, not write.
You have to use .css()
for this.
var tamanhoInicial = $(this).width(); // ou $(this).css('width');
$(this).css('width', tamanhoInicial - 20);