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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:45:43+00:00 2026-06-18T01:45:43+00:00

Kind of new to learning jQuery, I wrote this script. <script type=text/javascript> $(document).ready(function(){ alert($(#myInput).value);

  • 0

Kind of new to learning jQuery, I wrote this script.

<script type="text/javascript">
    $(document).ready(function(){
        alert($("#myInput").value);
        alert($("#myInput").length);
    });
</script>

<input id="myInput" value="Hello, World!" type="text" />

I don’t know why it is not why it always shows me:

undefined
1

While the expected outptu is:

Hello, World!
13

Please advice me. Thanks in advance.

  • 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-18T01:45:44+00:00Added an answer on June 18, 2026 at 1:45 am

    These kind of questions have been discussed and answered many times. Always, do a search before answering. Let me give you some suggestions.

    1. You have built-in functions like .val(), which is mainly used for getting the current value of the form inputs, when you have different types of them like textbox, checkbox, radio, textarea, and each of them use different types. So, change your first script this way:

      alert($("#myInput").val());
      
    2. The object returned by $("#myInput") would be a jQuery collection of elements. So, there is only one <input type="text" id="myInput" />. You need to use $("#myInput").val().length, and that gives the length of the value in the textbox. So, change your second script to:

      alert($("#myInput").val().length);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am kind of new to C# and Asp.Net, so this question might sound
So I'm kind of new to this, I'm writing a WIN32 app that records
I'm kind of new to using HTML/CSS for real, so this maybe a stupid
I am kind of new to JavaScript but I have a requirement where I
I'm kind of new to JQuery and was wondering how can I have the
I'm kind of new with CodeIgniter and I'm still learning (a lot). So I
I'm kind of new to the .NET platform. And currently I'm learning ASP.NET MVC.
I m a new one for selenium learning, I wonder that what kind of
I'm learning WPF, so I'm kind of n00b in this. I saw some examples
This is a kind of stupid simple question, I'm learning C++ and have the

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.