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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:56:51+00:00 2026-06-11T03:56:51+00:00

Assume I have an HTML document containing: <form id = my_form> <input type =

  • 0

Assume I have an HTML document containing:

<form id = "my_form">
    <input type = "text" />
    <input type = "text" />
    <input type = "text" />
    <button type = "button" onclick = "removeGoodInputs()">Do the job</button>
</form>

I want to get rid of the inputs values which satisfy some condition (given in my JS). I have tried creating my removeGoodInputs() function (as below), but this removes all inputs from the form. How can I resolve this issue?

function removeGoodInputs() {
    $("#my_form input").each(function() {
        if(this.attr("value") == 10)
            $(this).remove();
    });
}
  • 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-11T03:56:53+00:00Added an answer on June 11, 2026 at 3:56 am

    .attr() is a jQuery method so it can only be called on a jQuery object. Further, in jQuery .val() is the easier way to get the value (a shortcut).

    So, this line of your code is not correct:

    if(this.attr("value") == 10)
    

    I would recommend either:

    if (this.value == "10")      // plain javascript
    

    or:

    if ($(this).val() == "10")   // jQuery
    

    Note, I also changed the comparisons to be strings since that is what .value returns and it’s better to not rely on an automatic type conversion.

    You can see it work here: http://jsfiddle.net/jfriend00/HMemp/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net web form with an html input and button at the
Assume I have a vanilla form containing a selection list and a submit button:
Assume I have a dom_document containing the following html and it is put in
I have some code below: <!doctype html> <html lang=en> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8
assume I have a such html order <div id=header>>Header(logo, navigation menus etc)will be here,
Assume I have two tables, Student Test Id Name TestId Type StudentId -- ----
Assume I have an enumerable object enum and now I want to get the
Assume I have a set of numbers like 1,2,3,4,5,6,7 input as a single String
For intance, text/html, audio/mpeg, etc? Can I safely assume that anything that is text
From my previous question for selecting specific html text, I have gone through this

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.