I have the following code, which works fine in FF, but the .append() function s cauding an error in IE. Is anyone able to tell me if there is anything wrong with my code, or if this is an IE problem?
The purpose is to add a hidden field to a form (will be different depending on what the user clicks), and I then submit the form.
$(function(){
$('a.js-make-profile-image').click(function(){
$('.append-here').append('<input type="hidden" name="action-type" value="profile-image" />');
document.forms['attachment-action-form'].submit();
});
});
The IE debugger is giving the error Unexpected call to method or property access, and this text is being hightlighted within jQuery by the debugger – this.nodeType===1&&this.appendChild(a).
1) you have an extra
;at the end of this line.
if this don’t solve your problem please update your question with the error reported by IE
2) I think you could also have a conflict due to the value of your
nameattribute.You have both a
typeattribute andname="type":since you can usually access to a DOM element also via
<element>.<name>what exactly<input>.typeshould returns? The elementtypeattribute value or a reference to the input element into the DOM?so try to change the
nameattribute value3) if nothing has changed yet just try to change the code
in
and, as you discovered, be sure that the element
append-hereis not an empty element.