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 6384009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:43:16+00:00 2026-05-25T02:43:16+00:00

Using jquery, i would like to remove a hidden input, based on a class

  • 0

Using jquery, i would like to remove a hidden input, based on a class name selector but I just want to remove this inside of one specific form?

something like this:

$('.addToCartButton').click(function () {

    var form = $(this).closest('form');

    //remove all inputs with class name "test" inside of the form object above.

});

What is the best way of doing this?

Update


As a follow up question, how can i
1. First read each input val() into a variable before i remove it?
2. Get the first element from the find method (as it could return multiple elements)?

  • 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-05-25T02:43:17+00:00Added an answer on May 25, 2026 at 2:43 am

    this should do it

    $(form).find('input.test').remove();  //remove all elements
    

    http://api.jquery.com/remove/

    follow up:

    var firstItem=$(form).find('input.test')[0]; // only the first item
    
    var arr=[];  //this will build an array of the values
     $(form).find('input.test').each(function(){
        arr.push($(this).val());
      });
    
    var arr=[];  //this will build an array of the names andvalues with a comma between
     $(form).find('input.test').each(function(){
        arr.push($(this).name + "," + $(this).val());
      });
    

    loop through all values in array

    for(var i=0;i<arr.length;i++){
        alert(arr[i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the jQuery datepicker( http://keith-wood.name/datepick.html ) and I would like to set
I am using JQuery, and I would like to know if the remove() method
I am new to using jquery and would like to know how to append
I am relatively new to using jQuery and would like to use the load
I'm using jQuery Validate and would like to re-validate a group of fields whenever
I would like to manipulate the HTML inside an iframe using jQuery. I thought
I would like to print the selected values of all selects using jQuery. I
I'm using jQuery with the validators plugin. I would like to replace the required
I'm using jQuery validation in ASP.net MVC. I would like to show validation summary
Using xVal with Jquery validation and would like the error messages to be shown

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.