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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:54:54+00:00 2026-05-23T18:54:54+00:00

I want to know, how to dynamically change the value of a json property

  • 0

I want to know, how to dynamically change the value of a json property on a jquery event and then loads it up on the browser. Here’s the sample json.

var spiderman = {
   "fname" : "Peter",
   "lname" : "Parker",
   "nick" : "Spidey"
}

and here’s the event, let’s say… a click event

HTML code

Input a new nickname:<br />
<input type="text" id="newNick" />
<div id="pressMe">Press Me!</div>
<div id="output"></div>

jQuery event

$("#pressMe").click(function(){
   var newNick = $("#newNick").val();

   /* please place the correct code here */

   $("#output").text("Spiderman's new nick is " + spiderman.nick);
})

The goal is:
The user inputs the new nickname. When the user clicks #pressMe, it will get the value of #newNick and place it inside json to change the “nick” property. After that… it will show the new “nick” property on #output.

I hope its not confusing. Thank you!

  • 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-23T18:54:55+00:00Added an answer on May 23, 2026 at 6:54 pm

    This should work fine:

    spiderman.nick = newNick;
    

    Remember that if the JSON comes from an AJAX request and you loaded it with jQuery (or eval), then object properties are accessible as I wrote (even if you see them quoted if you look at the raw response). If you defined the JSON in memory, then you don’t need to use quotes on property names, but instead you should write:

    var spiderman = {
       fname : "Peter",
       lname : "Parker",
       nick : "Spidey"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show the value of a ComboBox in it's Change event handler.
Is it possible to subclass dynamically? I know there's ____bases____ but I don't want
i want know if is possible, to get a specific element value of a
want to know why String behaves like value type while using ==. String s1
I just would like to know how can I dynamically change a label's values
I want to create a two dimensional array dynamically. I know the number of
Dynamically, I would like to take a string property like GPARank and change the
I want my select box to dynamically change the CSS of another part of
I create select element dynamically using jquery, and I want to make action when
I want to know the most effctive way to dynamically update, insert or remove

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.