Reputation: 393
I have the follow HTML code:
<input id="user_current_password" name="user[current_password]" size="20" type="password" style="display: none;">
I want to remove the size attribute. I already tried things like:
$("#user_current_password").removeAttr("size")
$("#user_current_password").attr("size","auto")
$("#user_current_password").attr("size","")
But it always give me the error: DOMException: Failed to set the 'size' property on 'HTMLInputElement': The value provided is 0, which is an invalid size.
Thanks
Upvotes: 1
Views: 2335
Reputation: 73231
This should solve it, using javascript only:
var a = document.getElementById('user_current_password');
a.setAttribute('size','auto'); // <<< set size as wished
Or, to remove it:
a.removeAttribute('size');
Please note to place this code within
window.onload = function() { /* code */ }
as the DOM has to be loaded in order to let the code find the Elements
Upvotes: 2