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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:52:38+00:00 2026-06-13T11:52:38+00:00

I use Google Chrome. I need to have a very tiny HTML editor and

  • 0

I use Google Chrome.

I need to have a very tiny HTML editor and I found Simple Edit. Very small editor, just for my needs. However… This and many other editors that are using Content Editable have one common problem.

Problem

After creating a list (hit enter twice on last list item), it creates a new div. Expected to me would be to create a new paragraph tag.

Links

  • Try the editor here: http://files.inlovewithcss.com/simple-edit/
  • Look at the tiny source code: https://github.com/mlabod/simple-edit/blob/master/editor.jquery.js

Question

What is the correct way of prevent divs, and instead add paragraph tags after a list?

  • 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-13T11:52:39+00:00Added an answer on June 13, 2026 at 11:52 am

    The answer posted by Bryan Allo did not take into account that you need to place the cursor at the end of the div. Otherwise upon every replace action the user would have to hit CTRL-End.

    This is the solution I propose, also to be seen in action at http://jsfiddle.net/82dS6/:

    function setEndOfContenteditable(contentEditableElement){
        // Taken from http://stackoverflow.com/a/3866442/1601088
        var range,selection;
        if(document.createRange){//Firefox, Chrome, Opera, Safari, IE 9+
            range = document.createRange();
            range.selectNodeContents(contentEditableElement);
            range.collapse(false);
            selection = window.getSelection();
            selection.removeAllRanges();
            selection.addRange(range);
        }
        else if(document.selection){//IE 8 and lower
            range = document.body.createTextRange();
            range.moveToElementText(contentEditableElement);
            range.collapse(false);
            range.select();
        }
    }
    
    function replaceDivWithP(el){
    
        $(el).find('div').each(function(){
            $(this).replaceWith($('<p>' + $(this).html() + '</p>'));
        });
    }
    
    $(function(){
        $(".text").simpleEdit();
    });
    
    $('.textarea').bind('keyup', function(){
        replaceDivWithP(this);
        setEndOfContenteditable(this);
    });
    
    
    ​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write a small Google Chrome extension in which I use
I am developing a Google Chrome extension, and need to use the chrome.experimental.webRequest API.
I would like to use Google Chrome instead of the WebKit Framework in one
how can I use jQuery in my google chrome extension without conflicting with the
I am trying to use Google App Engine's app.yaml to automatically serve *.html files
I am trying to use Google's libjingle framework and need to broadcast a query
I'm writing an extension for Google Chrome where I need to download the images
I have this piece of HTML <select multiple= name=colonia_id[] id=colonia_id[] onchange= size=10></select> I need
I am just starting writing chrome extension. I need an advice on what should
For unknown reasons, when I use Google chrome (version 9.0.597.84), the developer tools aren't

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.