Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8058773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:27:23+00:00 2026-06-05T09:27:23+00:00

THis is how i am trying (no firebug errors) to restore each select of

  • 0

THis is how i am trying (no firebug errors) to restore each select of my form to its first option value

/* $(this) is the form */
$(this).find('input[type="text"],textarea').val(''); /* This works */
$(this).find("select").each(function(){
    $(this).val($(this,"option:first").val());  /* this doesnt do anything */
});

what am i doing wroing?

-edit-

just found out.. this works, why not with the comma?

$(this).val($(this).find("option:first").val());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:27:24+00:00Added an answer on June 5, 2026 at 9:27 am

    Just try this:

    $(this).find("select").change();
    

    This will automatically set the first option value as default.

    If you use you code you need:

    $(this).find("select").each(function(){
    
        $(this).val($("option:first", this ).val());  /* this doesnt do anything */
    
                                       ^--- this will places here
    
    });
    

    Your $(this, "option:first") not worked because you code is searching a select within a option, but it should search option within search.

    One format of jquery selector is

    $(target, context);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying this query: SELECT * FROM superpart WHERE Brick_subpart_id = 603 OR 145;
I was trying this problem, http://www.spoj.pl/problems/TWOSQ/ . We have to find the number of
I am trying this but its going to else part always <c:forEach items=${records} var=field
I am trying out jqueryUI, but firebug catches the following error on this script:
I'm trying to get FireBug Lite working with IE7. Given this code (and nothing
Im trying this, but when i press it it dont changes, it only displays
I was trying this: $(document).ready(function () { $(.qa-a-count).appendTo(.qa-q-item-main); }); But there are a lot
I'm trying this jQuery way of pub-sub and it works only partially: <button id=button1>click1</button>
i am trying this code since last night but i cant understand what this
I am trying this function, however something is wrong. I stored the name John

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.