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

  • Home
  • SEARCH
  • 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 7911701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:20:51+00:00 2026-06-03T13:20:51+00:00

I am novice to jquery and asp.net. I am using the following coding to

  • 0

I am novice to jquery and asp.net. I am using the following coding to retrieve value. Why [0] in $(#textbox1)[0].value is used? is there any alternative way to retrieve value?.

$.ajax({
                     type: "POST",
                     url: "Default.aspx/GetTextData",
                     data: "{}",
                     contentType: "application/json",
                     dataType: "json",
                     success: function(msg) {
                       $("#txtResult")[0].value = msg.d;
                     }
                 });

Many Thanks

  • 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-03T13:20:52+00:00Added an answer on June 3, 2026 at 1:20 pm

    In the context of your code, it’s not actually retrieving value, it’s setting:

    $("#txtResult")[0].value = msg.d

    You can use the alternative, jQuery syntax of (as per my comment):

    $('#txtResult').val(msg.d)

    It’s required to use [0] as the author of that code would like to assign a value to the standard DOMElement of the input, as [0] is used to get the native DOMElement from that jQuery object. Alternatively you can use:

    $('#txtResult').get(0).value = msg.d

    Although the previous way is still preferrable

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

Sidebar

Related Questions

I am using ASP.NET MVC with jQuery. I have the following MVC Action that
I have an ASP.NET MVC application and I am using two JQuery plugins: colorbox
Using JQuery, is there a more efficient way of writing this code? See below
I am a noivce at JQuery. I'm curious about if there is any plug-in
I have a simple JQuery enabled ASP.NET page: <script> $(document).ready(function() { $(#accordion).accordion(); }); </script>
I am updating one of my sites from asp.net with jQuery UI to use
I'm a jQuery novice, I have the following jQuery written to show a div
With ASP.NET MVC3 (Razor) I have a simple page that loads a jQuery UI
I follow directions well but am still a novice in jquery. I installed using
I read ScottGu's blog entry ( http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx ) a while back, and it seems

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.