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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:17:15+00:00 2026-05-27T19:17:15+00:00

What I am making is basically is a user profile that has a text

  • 0

What I am making is basically is a user profile that has a text box for description added by the user about himself/herself. Although I have a separate page where the user can edit the profile, but I want to provide a feature that when a user hovers over his description box then he sees an edit button.

If the user clicks that button, then he/she can edit the description field there itself, and the backend will be updated using Ajax. The ajax call and the backend processing is simple, but how can I replace the html with a textarea and submit button and again put back the original html using javascript.

Here is what my html look like

<div id="personalText" >
    <a href="#" id="editButton"> edit </a>
    <p id="descText">{{profile.desc}}</p>
</div>

When somebody clicks editButton I want to replace the html inside personalText with a textarea containing the original text in descText, and an update button. And when the user edits the text and click update, I will update the backend model and again put the <a> tag and the <p> tag.

Can anybody help. I seem to know how to do parts of it, but can’t figure out how I will replace the original structure on update click.

  • 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-27T19:17:15+00:00Added an answer on May 27, 2026 at 7:17 pm

    Instead of creating/destroying DOM elements an option would be to have the edit <textarea/> hidden.

    <div id="personalText" >
        <div class="display">
            <a href="#" id="editButton">edit</a>
            <p id="descText">{{profile.desc}}</p>
        </div>
        <div class="edit" style="display:none;">
            <input type="submit" value="Update"/>
            <textarea>{{profile.desc}}</textarea>
        </div>
    </div>
    

    Then your jQuery can simply toggle the elements and handle your ajax post.

    $("input[type='submit']").on("click", function() {
        $.ajax({
            url:"/your/url/"
        }).success(function(){
            $(".display, .edit").toggle();
            $("#descText").html($("textarea").val());
        });
        return false;
    });
    

    Example on jsfiddle

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

Sidebar

Related Questions

So I'm basically making an app that adds a count to a number and
I'm making a Stored Procedure that basically concatenates a long string with data from
Long story short, I'm making a custom Swing component that's basically a JTable with
I have a problem with web.py. Basically the user clicks a button, which makes
I have a UITableView and basically I'm making some in app settings, and if
For example the Exif standard has a User Comment tag that has a limit
I have a relatively simple case. I basically want to store data about links
I have a usercontrol on a page that has a login control in it.
I'm making a really simple email validation script that basically just checks the following
I am making an app which basically presents data (from plist) to user in

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.