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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:29:34+00:00 2026-05-14T18:29:34+00:00

What is the javascipt code that will edit a text on double click. The

  • 0

What is the javascipt code that will edit a text on double click. The process is I have a text and if I double click it, a text box will appear, and if I press enter the word will change depends on what you’ve type.

Sample

This is sample text. $nbsp;$nbsp; --> if I double click it a textbox will appear.
<input type="text" value="This is sample text." name="" />

Sorry for asking this. I am a newbie in javascript

  • 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-14T18:29:35+00:00Added an answer on May 14, 2026 at 6:29 pm

    Here is a great example.

    I’m going to paste in the script from that example so that it’s preserved in case that link goes away, but you should follow the link — the article does a great job of breaking the script down line by line and explaining what it does. A great learning opportunity for javascript.

    var editing  = false;
    
    if (document.getElementById && document.createElement) {
        var butt = document.createElement('BUTTON');
        var buttext = document.createTextNode('Ready!');
        butt.appendChild(buttext);
        butt.onclick = saveEdit;
    }
    
    function catchIt(e) {
        if (editing) return;
        if (!document.getElementById || !document.createElement) return;
        if (!e) var obj = window.event.srcElement;
        else var obj = e.target;
        while (obj.nodeType != 1) {
            obj = obj.parentNode;
        }
        if (obj.tagName == 'TEXTAREA' || obj.tagName == 'A') return;
        while (obj.nodeName != 'P' && obj.nodeName != 'HTML') {
            obj = obj.parentNode;
        }
        if (obj.nodeName == 'HTML') return;
        var x = obj.innerHTML;
        var y = document.createElement('TEXTAREA');
        var z = obj.parentNode;
        z.insertBefore(y,obj);
        z.insertBefore(butt,obj);
        z.removeChild(obj);
        y.value = x;
        y.focus();
        editing = true;
    }
    
    function saveEdit() {
        var area = document.getElementsByTagName('TEXTAREA')[0];
        var y = document.createElement('P');
        var z = area.parentNode;
        y.innerHTML = area.value;
        z.insertBefore(y,area);
        z.removeChild(area);
        z.removeChild(document.getElementsByTagName('button')[0]);
        editing = false;
    }
    
    document.onclick = catchIt;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some Javascript code that needs to be dynamically created as a String
I have a simple jQuery function that resizes text areas, and I want it
I'm pretty new to javascript and jquery, and have run into a problem that
If you look at the homepage of http://beta.gulfdine.com/ , you will note that the
I have another Javascript regex conundrum... (apologies if this is a bit long-winded -
[ Edit: I'm replacing the original, confusing question with a simplified example demonstrating the
i am currently working on a program in jquery. My program works fine in
Ok so I've been stumped on this one for days and its frustrating me.
I feel like an idiot because I've spent a long time trying to find
I am using asp.net mvc 3 jquery validate unobstructive javascript. I am trying to

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.