Bug Tracker

Modify

Ticket #1286 (closed bug: fixed)

Opened 6 years ago

Last modified 4 years ago

"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:
Blocking: Blocked by:

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

comment:1 follow-ups: ↓ 2 ↓ 3 Changed 6 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 6 years ago by brandon

  • Component changed from event to docs
  • Summary changed from No bind for 'reset' event to "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 6 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 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.