Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: '[object HTMLInputElement]' is not a function (evaluating 'elem[ type ]()') in jQuery form.submit()

Has never run into this issue? I'm getting this error in the latest release of jQuery. I tried with version 1.6.2 and there is no issue.

TypeError: '[object HTMLInputElement]' is not a function (evaluating 'elem[ type ]()')

line 3175

Has anything changed that we should be aware of?

Thanks, Jack

like image 356
juminoz Avatar asked Dec 29 '11 20:12

juminoz


2 Answers

This usually happens if any of your input tag's name is submit. For example,

<form id="frm">
    <input type="submit" name="submit" value="Post" />
</form>

On the above code, document.getElementById("frm").submit represents the input element. When you apply () to submit It shows this error.

like image 53
Shiplu Mokaddim Avatar answered Sep 25 '22 01:09

Shiplu Mokaddim


I have found that this error will occur when using the onclick attribute to call a JavaScript function with the same name as either the id or name attributes on an input element:

<input id='foo' name='fooName' onclick='foo();'> <!-- BAD: id matches function -->

<input id='fooId' name='foo' onclick='foo();'> <!-- BAD: name matches function -->

<input id='fooId' name='fooName' onclick='foo();'> <!-- WORKS! -->

This behavior occurs irrespective of input type.

like image 20
Peter Gluck Avatar answered Sep 27 '22 01:09

Peter Gluck