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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:49:29+00:00 2026-05-27T20:49:29+00:00

I have a div contentEditable with paragraphs and appended after each p is a

  • 0

I have a div contentEditable with paragraphs and appended after each p is a span telling me the length of the paragraph the user can edit the line & thus update the number shown in the span, (done with something on these lines .each(fu..(){ p append ‘<span>’+ this.length ..)

Let’s say something like this:

<div contenteditable="true">
<p>abc<span contenteditable="false" style="position:absolute;right:-2em;backg...">3</span></p>
<p>abce<span ...>4</span></p>
<p>abcfoo<span ...>6</span></p>
<p>abcbar<span ...>6</span></p>
</div> 

Have made all the spans uneditable in order to protect the spans and the text, on hitting return a new <p> is created on the next line – all sparky! However I have no way of deleting a new paragraph as the back button on the first letter of a p acts as the browser back button! because its hitting the non editable span.

So I would like to add a button (perhaps on the span) which when clicked will 1. remove the span (not too difficult), 2. merge the 2 paragraphs together.

  • 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-27T20:49:29+00:00Added an answer on May 27, 2026 at 8:49 pm

    I hope that’s the effect you’re looking for: http://jsfiddle.net/AwKkB/

    JS

    $('span').click(function () {
        var parent = $(this).parent(), container = parent.parent();
        $(this).remove();    
        if (container.children().length > 1) {
            if (parent[0] === container.children()[0]) {
                $(container.children()[1]).prepend(parent.text());
            } else {
                parent.prev().append(parent.text());
            }
        }
        parent.remove();
    });
    

    HTML

    <div contenteditable="true" style="width: 180px">
    <p>abc<span contenteditable="false" style="position:absolute;right:0em;background: red;">3</span></p>
    <p>defg<span contenteditable="false" style="position:absolute;right:0em;background: red;">4</span></p>
    <p>hijklm<span contenteditable="false" style="position:absolute;right:0em;background: red;">6</span></p>
    <p>nopqrs<span contenteditable="false" style="position:absolute;right:0em;background: red;">6</span></p>
    </div> 
    

    Best regards!

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

Sidebar

Related Questions

Let's say I have a contentEditable div , to the user can edit and
For example, I have a contentEditable div and I can type in it. When
I have a contenteditable div and when you type in it, after 2 seconds
I have a CONTENTEDITABLE div and inside that div I have a CONTENTEDITABLE span,
have this html: <div id=editable contentEditable=true > <span contentEditable=false >Text to delete</span> </div> need
I have a contenteditable div where users can enter up to about 20kb of
I have a contentEditable div in a UIWebView. I want to disable the spell
I've deleted the old post here. I have a contentEditable div. If you paste
I have a contenteditable div where I need to insert text at the caret
I have a contenteditable div that I want users to be able to select

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.