Bug Tracker

Opened 16 years ago

Closed 14 years ago

#1286 closed bug (fixed)

"Getting Started with jQuery" tutorial out of date

Reported by: schettino72 Owned by:
Priority: minor Milestone: 1.1.3
Component: docs Version: 1.1.2
Keywords: Cc:
Blocked by: Blocking:

Description

I just started to use JQuery. I was folowing the tutorial "Getting Started with jQuery" and I got an error when trying to execute this example:

$(document).ready(function() {
   // use this to reset a single form
   $("#reset").click(function() {
     $("#form").reset();
   });
 });

Firebug:

$("#form").reset is not a function
[Break on this error] $("#form").reset();

I checked the API (and the code) and this event is not there. I guess it should. If not, the problem is in the tutorial.

Change History (4)

comment:1 Changed 16 years ago by jakecigar

$("#form") is a jQuery object. $("#form")[0] is the dom element. $("#form")[0].reset() resets the form.

use $("#form")[0].reset() to reset your form.

comment:2 in reply to:  1 Changed 16 years ago by brandon

Component: eventdocs
Summary: No bind for 'reset' event"Getting Started with jQuery" tutorial out of date

Replying to jakecigar:

$("#form") is a jQuery object. $("#form")[0] is the dom element. $("#form")[0].reset() resets the form.

use $("#form")[0].reset() to reset your form.

In addition to what Jake said the API was cleaned up a while back and it looks like maybe the tutorial hasn't been updated.

comment:3 in reply to:  1 Changed 16 years ago by MattPenner

Replying to jakecigar:

use $("#form")[0].reset() to reset your form.


I ran into this same problem and found this ticket. The tutorial needs to be updated.

In addition to jakecigar's fix for the single form use:

$("form").each(function() {
   $(this)[0].reset();
});

to reset all the forms on the page as the tutorial attempts to do.

comment:4 Changed 14 years ago by dmethvin

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.