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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:26:20+00:00 2026-06-10T09:26:20+00:00

I have got a button ‘edit description’ when I click on it text disappear

  • 0

I have got a button ‘edit description’ when I click on it text disappear and appear

        if (id == 'commedit') jQuery(this).html('<textarea>'+jQuery(this).text()+'</textarea>');
        else if (id == 'commsave') {
            jQuery(this).text(jQuery(this).find('textarea').val());
        }

In MySql I have this text – "tetee<br>afafaf<br>afafaf<br>afsafsasfasf" in view it dispays with line breaks but when I click ‘edit’ in text area which come with Jquery text appear without lines and when I click save it also appear in my description field in one long line without line breaks. So I need your help

  • 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-10T09:26:22+00:00Added an answer on June 10, 2026 at 9:26 am

    <br> are html breaks. You want \n in a textarea.

    jQuery(this).html().replace(/<br>/gi,"\n")
    

    When you save, you want to change it back to breaks and use html() instead of text();

    var elem = jQuery(this);
    if (id === 'commedit') {
        var text = jQuery(this).html().replace(/<br>/gi,"\n");
        elem.html('<textarea>'+ text +'</textarea>');
    } else if (id === 'commsave') {
        var html = elem.find('textarea').val().replace(/\n/g,"<br>");
        elem.html(html);
    }
    

    JSFiddle Example

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

Sidebar

Related Questions

I have got jquery post function jQuery('.more-button').live('click', function(eve){ var page = jQuery(this).attr('id').replace('more-button-',''); loaded_messages +=
I have got this html: <a style=display:block; padding:100%; text-decoration: none; href=http://google.com class=Jasmin id=target_site_to_visit> <span
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have got this button which uses onclicklistener and onlongclicklistener, but also a button
I have got this code and I need to access somehow Button and call
In my html i have got div with given class. After clicking a button
I have got this button: <input type=button value=Rep id=rep name=rep class=rep style=width:50px onclick=triggerLabel(1);this.disabled=true;addRep(<?php echo
I have got a button field in my grid view. When I click multiple
I have got some markup that looks like this: <div class=button> <span class=image></span> <input
I have got a dropdownlist, a submit button and a textbox in my view.

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.