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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:48:12+00:00 2026-06-11T12:48:12+00:00

Line breaks and carriage returns… Must be the most complicated part of coding. (for

  • 0

Line breaks and carriage returns… Must be the most complicated part of coding. (for me)

Have this code in a page (which came from database stored as This from Ricardo\nAnd also a test\nRent 3000.00):

<td title="This from Ricard
And also a test
Rent 3000.00" style="width:198px;text-align:left">....</td>

Then use this to get the title attribute with ‘hidden’ \n’s

var v = $('#'+i).parent().attr('title');        // i = id of <span> child of <td>

Along the way, the line breaks get lost and using the variable v into a text input box:

This from RicardAnd also a testRent 3000.00

What does it take to preserve the \n's and have this look instead like below?

Screenshot of desired result (with \n's present) after clicking edit

  • 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-11T12:48:13+00:00Added an answer on June 11, 2026 at 12:48 pm

    The line breaks are still there, it is just that the browser tries to render them.

    If you still want to see the “\n” try this:

    var v = $('td:first-of-type').attr('title').replace(/\n/g, "\\n");
    

    Else, if what you want is NOT to see the “\n” and instead see the line breaks, you could do it this way:

    var v = $('td:first-of-type').attr('title').replace(/\n/g, "<br/>");
    

    Check this JSBin

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

Sidebar

Related Questions

I have a text file (txt) containing formatted text (just line breaks, carriage returns
Does file_get_contents maintain line breaks? I thought it did but I have tried this:
I am doing this to replace whitespaces and line breaks. The whitespaces part works
I would like to remove any line breaks/carriage returns at the start and end
I need to find and clean up line breaks, carriage returns, tabs and SUB-characters
I have number of line breaks in a string. But I only want it
My file has a lot of line breaks, like this: This is a line.
/* Suppose I have a multi-line comment with hard line-breaks * that are roughly
I want to prevent line breaks between two forms I have. So basically: <form
My columns have line breaks, but how can I convert these to vbCrLf when

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.