www.webdeveloper.com
Results 1 to 1 of 1

Thread: Select parent form for a given input

  1. #1
    Join Date
    Dec 2008
    Posts
    488

    Question Select parent form for a given input

    I have the following code:

    Code:
    $(function() {
        // Attach onclick event to Clear buttons on all forms
        $('.resetForm-mthdClear').click(
            function() {
                // Reset the form
                this.form.reset();
                // Remove selected="selected" from Select options
                $(this.form).find('option:selected').attr('selected','');
            }
        );
    });
    Is there any reason why "this.form" wouldn't work in some browsers/operating systems? I thought it was pretty standard, but a user complained that the button wasn't doing anything for them in Firefox/Windows 7.

    Should I use:
    Code:
    $(this).closest('form').each(
        function() {
            this.reset();
        }
    });
    instead?
    Last edited by jamesbcox1980; 03-17-2011 at 09:23 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles