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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:26:22+00:00 2026-05-25T03:26:22+00:00

I am trying to fix a problem for hours and I just gave up

  • 0

I am trying to fix a problem for hours and I just gave up trying to search & code & see if it works.

Maybe it will be better to explain with simple code what I am trying to do;

<script>
test1       = $('input:text[name=test1]');
test2       = $('input:text[name=test2]');
test3       = $('input:text[name=test3]');

var obj = [];
obj.push(test1);
obj.push(test2);
obj.push(test3);

$.each(obj, function(key, value) {
    console.log ('value : ' + value.val());
});

</script>
</head>

<body>
<input name="test1" type="text" value="1"/>

<input name="test2" type="text" value="2"/>

<input name="test3" type="text" value="3"/>
</body>
</html>

What I am trying to do is;

  1. Define variables which will be assign to DOM element.
  2. Create an array and put those variables which are assigned to DOM elements.
  3. Loop them and get their values etc…

Is there a way to do that? I am really tired after trying to make it work for hours.

Thank you for your help and time in advance.

EDIT:

Of course the code above wasn’t something I was trying to achieve. I have a form which has over 700 lines of Jquery code and I had a problem in one of my functions.

The principle was the same so I decided to make something really short and clearly understandable.
$value was just bad copy & paste. Before I realized I didn’t delete all of my old code (just $ was left) and edited my post, some people already replied. It wasn’t the correct answer but I just didn’t want to close the question without giving points to anyone.

The code above will not work unless if you change it to;

$(document).ready(function(){
 // Put the code here
});

Considering my jquery code is in between <head> </head> I have to use $(document).ready

I hope this will help someone.

I am not newbie in Jquery, I don’t know why and how I could make such mistake.

  • 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-25T03:26:23+00:00Added an answer on May 25, 2026 at 3:26 am

    Try doing this:

    $.each(obj, function() {
        console.log ('value : ' + this.val());
    });
    

    Demo

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

Sidebar

Related Questions

I'm trying to fix a problem with some code (not written by me) lnkbtnPageNumber.ID
I just have a problem that I have been trying to fix for the
I've been trying to fix this for two hours straight and I can't figure
I have been trying to solve this problem for hours (searched here as well
I'm trying to fix some JavaScript bugs. Firebug makes debugging these issues a lot
I am trying to fix memory leaks in IE 7. Using Drip for investigations
Hi I'm trying to fix a bit of test html to work with opera/chrome.
I am trying to fix a bug with SSL in a product and noticed
i am trying to fix a site I am helping a friend with, and
I'm trying to fix a bug in a rich text editor I'm using, which

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.