<input id="mnc" type="text"/>
<input type="text" id="selected" />
$('#mnc').val().length ? $('#selected').attr({
'size': $('#mnc').val()
}) : $('#selected').removeAttr('size');
This gives an error in Firefox 4.
Index or size is negative or greater than the allowed amount" code: "1
Other browsers are able to handle removeAttr even if attribute does not exist. What i'm doing is checking if input #mnc is empty then remove attribute size from #selected whether it exists or not.