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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:20:43+00:00 2026-06-08T19:20:43+00:00

I am trying to make editable text. What I have is a line of

  • 0

I am trying to make editable text. What I have is a line of text that you click and I need an text box to appear, allowing the user to change the value of the text. With the code that I do have, when you click the text disappears. Any ideas?
html

       <div class="test">Click here</div>

jquery

       $(".test").click(function() {
           var inputValue = $(".test").text();  
           $(".test").html("<input value='"+inputValue+"' 
               type='text' id='box1'>");
           $("#box1").val(inputValue).select();
        });
  • 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-08T19:20:44+00:00Added an answer on June 8, 2026 at 7:20 pm

    Maybe it would be simplier if you will use existing solutions. For example: jeditable

    But if you want (See DEMO):

    $(document).ready(function () {
        var beginEdit = function () {
            var text = $(this).text();
            var input = $('<input value="' + text + '" type="text">').one('blur', endEdit);
    
            $(this).empty().append(input);
        };
    
        var endEdit = function () {
            var text = $(this).val();
            $(this).parent().html(text).one('click', beginEdit);
        };
    
        $(".text").one('click', beginEdit);
    });​
    

    As a plugin for jQuery (see DEMO2):

    $.fn.editable = function () {
        this.each(function () {    
            var beginEdit = function () {
                var text = $(this).text();
                var input = $('<input value="' + text + '" type="text">').one('blur', endEdit);
    
                $(this).empty().append(input);
            };
    
            var endEdit = function () {
                var text = $(this).val();
                $(this).parent().html(text).one('click', beginEdit);
            };
    
            $(this).one('click', beginEdit);        
        });
    };
    
    $(document).ready(function () {
        $(".text").editable();
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to make a text box no editable for the users. I
I'm trying to make a viewpager that has editable text, but I don't want
I am trying to make editable listbox that gives user ability to update listitem
I am trying to make an editable text object in cocoa that contains no
I'm trying to change the value of an Editable-Text control in Allegro CL (version
Okay, so I'm trying to make this action change a user-editable textfield if the
I have a ListBox in a Silverlight Application. I'm trying to make an editable
I am trying to do a simple task: I have an editable text field,
I'm trying to make an alert box that appears only when the app is
I'm trying to make an EditText non editable with this code: <EditText android:id="@+id/outputResult" android:inputType="text"

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.