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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:30:14+00:00 2026-06-17T14:30:14+00:00

Below, I am trying to iterate through each attribute in an input element. It

  • 0

Below, I am trying to iterate through each attribute in an input element. It isn’t working and I’m not sure why. Is this an incorrect use of the object named input? How do I change this?

<script>
   $('form.trade').submit(function(e) {
      e.preventDefault();
      input=$(this).find(':input:first');
      value='';

      $.each(input.attributes, function(i, attrib){
        if (attrib.name!='type'){
            value +=attrib.name + ":" + attrib.value + ";";
        }
      });
      });
</script>
<form class="trade" id="24243">
<input type="hidden" available="4" pid="24243" cardname="something" yay="blah">
Available: <p class="available">4</p>
<input type="submit" value="add card">
</form>
<br/>
<form class="trade" id="24245">
<input type="hidden" available="7" pid="24243" cardname="somethik" yay="blakk">
Available: <p class="available">7</p>
<input type="submit" value="add card">
</form>
  • 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-17T14:30:16+00:00Added an answer on June 17, 2026 at 2:30 pm

    It’s “attributes” on the input array that doesn’t make sense.

    $.each(input.attributes
    

    The result of $(this).find(':input') returns a jQuery selection (array) of items.

    Are you trying to iterate through the inputs attributes? $.each(input[i].attributes is what you’re looking to do, where i is an iterator through the input collection.

    ~ Here’s what you want to do:

    <script>
          $('form.trade').submit(function(e) {
               e.preventDefault();
               var $inputs=$(this).find(':input:first');
               var value='';
               $inputs.each(function(i,input){
                 $.each(input.attributes, function(j,attrib){
                     if (attrib.name!=='type'){
                    value +=attrib.name + ":" + attrib.value + ";";
                     }   
                 });
               });
               console.log(value); // what do you want to do with value??
          });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I'm trying to use reflection to iterate through a class to get all
Related to this question here . I'm trying to iterate through a series of
From the XML below I'm trying to retrieve the second element in the sequence.
I have 3 HTML lists that I am trying to iterate through check which
I'm trying to iterate through a nested object to retrieve a specific object identified
I am trying to yield iterate through a collection and if the collection is
I was trying to iterate in loop through text boxes and assign values to
So I'm trying to iterate through a list of files that are within a
I'm trying to use CFmail in a CFScript CFC. I want CFMail to iterate
I'm following this post and trying to run the code (copied below), and I'm

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.