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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:57:25+00:00 2026-06-04T06:57:25+00:00

Trying to copy some user input from one HTML input to another and my

  • 0

Trying to copy some user input from one HTML input to another and my console is showing an error: Uncaught TypeError: Object #<HTMLInputElement> has no method 'val'

Not sure what the issue is.. I thought that a text input does have a value? Thanks for your help!

HTML:

<input id="a" class="answer" type="text">
<input id="af" type="text" name="a">


$('.answer').bind('keypress', function(){
    var name  = $(this).attr('id'),
        feild = $('#' + name + 'f')[0];

    feild.val($(this).val());
});
  • 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-04T06:57:26+00:00Added an answer on June 4, 2026 at 6:57 am

    Edit: As @zerkms pointed out, the [0] is not needed anyways, but since it’s sometimes useful to use array indices with selectors, I’ll leave this here so you understand the error.

    Change:

    field.val($(this).val());
    

    to

    $(field).val($(this).val());
    

    Explanation: $('#' + name + 'f') gets an array of HTML elements that match the selector. Since you put [0] this gets the first HTML element in the array. Since field is a HTML element rather than a jQuery object, you need to convert it to a jQuery object using $(field) to use jQuery methods on it.

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

Sidebar

Related Questions

I am trying to copy an SPListItem (with file) from one site collection to
I am trying to copy one table over another one atomically. Basically I want
I got some troubles trying to copy char to char... Here's args[] definition :
I'm trying copy a single file from the Plugin directory inside of my Wordpress
I am trying to copy a file from my remote server to my local.
I am trying to copy the contents of certain folders to another folder using
I am trying to copy data from my MYSQL table to SQL Server using
Im trying to make some text non-copyable, my aim isn't to stop people from
I'm trying to launch a request for some data from an external website w/
I'm trying to setup a html form that will take a file from a

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.