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

  • Home
  • SEARCH
  • 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 7843663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:37:14+00:00 2026-06-02T16:37:14+00:00

I have an div element <div id=form><form id=formstuff>form input stuff</div></div> that shows/hides (or toggles)

  • 0

I have an div element

<div id=form><form id="formstuff">form input stuff</div></div>

that shows/hides (or toggles) when users clicks on another element

<div id="close"></div>

If #form is shown and user decides to input values, but suddenly decides to just click on the #close button to close the #form element without deleting the values. How would you delete all input values when the user decides to close #form or hide()?

Is the only way to do something like $(this).val(''); Or is there something like .empty(); but I don’t want to remove style and such, just the text.

  • 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-02T16:37:16+00:00Added an answer on June 2, 2026 at 4:37 pm

    Try this: http://jsfiddle.net/96FJp/

    UI:

    <form id="thisForm">
        <input type="text" value="HellO">
        <input type="text" value="World">
    
        <input type="button" value="wow"/>   
    </form>
    
    <input type="button" id="test">​
    

    jQuery:

    $('#test').click(function() {    
        $('input:not([type=button])', '#thisForm').val('');
     });
    

    ​


    To include other inputs, just put a comma on jQuery selector, do this: http://jsfiddle.net/dpRJy/1/

    UI:

    <form id="thisForm">
        <input type="text" value="HellO">
        <input type="text" value="World">
    
        <input type="button" value="wow"/>  
    
        <select id="country">
            <option value="">--Select Country--</option>
            <option value="PH">Philippines</option>
            <option value="CN" selected>China</option>        
            <option value="CA">Canada</option>                
        </select>      
    
        <br/>
        <input id="drink" type="radio" name="drink" value="Water"> Water<br>
        <input id="drink" type="radio" name="drink" value="Beer"> Beer<br>
        <input id="drink" type="radio" name="drink" value="Wine" checked>Wine<br/>    
    </form>
    
    <input type="button" id="test">​
    

    jQuery:

    $('#test').click(function() {    
        $('input:not([type=button]),select', '#thisForm').val('');
    
        // radio button doesn't fit nicely to method val value clearing,
        // have to do this:
        $('input:radio','#thisForm').prop('checked', false);
     });
    ​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a container element say <div id=myContainer> <form action= method=post> Radio: <input type=radio
I have a form element defined as: <div class=field> <div class=name> <label for=User_LastName> Last
I have a div element containing some text. When the user clicks a word
Within an web form I have a some input fields <div id=search1> <div class=forminput>
I have a form with a table that has two input boxes, a select
i have a form element- text input and a submit button- Im trying to
i have the following function in jQuery and javascript that creates a form element:
I have next code for element form select: <div style=width: 300px; margin: 0 auto;
Please help! I have some form elements in a div on a page: <div
I have a div element with fixed height and width and overflow:hidden, and I

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.