Why does $ ("# form") [0] .reset (); 'work and "$ (" # form "). reset (); ' not?

I am using the reset method as shown below on my web pages

$("#form")[0].reset();

But when I use it as below

$("#form").reset();

This gives me an error.

Why does the first method work, and later not?

My page is working fine. But I would like it to be behind. There is a solution everywhere. But none of them describes the reason for this.

Note: I checked here and it shows so many answers. Nothing clearly defines the cause.

+4
source share
3 answers

, , javascript Jquery

.reset() JQuery. javascript, Jquery

+1

jQuery , . jQuery, , DOM .

, , [0], , :

$('#form').each(function() { this.reset() });
+5

reset() HTML:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset

And not the method suggested by the jQuery object, which is a collection of 0 or more matching elements for your selector ( #form)

+4
source

All Articles