If I'm clearing a form with 5 or more fields in IE11 using $('form input').val("") IE11 will crash. HTML:
<form>
<label>1</label><input type="text"/>
<label>2</label><input type="text"/>
<label>3</label><input type="text"/>
<label>4</label><input type="text"/>
<label>5</label><input type="text"/>
</form>
JS:
$(document).ready(function(){
$('#clearFormNormal').click(function(){
$("form input").val("");
});
});
When I'm doing this recursive and with a setTimeout it works.
JS:
function clearFields (counter) {
var i = counter || 0, deferred = new $.Deferred();
if ($("form input").eq(i).length === 1){
setTimeout(function(){
$("form input").eq(i).val("");
i = i + 1;
clearFields(i).always(function(){
deferred.resolve();
});
},0);
} else {
deferred.resolve();
}
return deferred.promise();
}
$(document).ready(function(){
$('#clearFormSetTimeout').click(function(){
clearFields();
});
});
See the http://jsfiddle.net/fransoverbeek/Cy5D5/7/ as well
Is this an IE11 bug?