Note that there are some explanatory texts on larger screens.

plurals
  1. POClosing <ul /> tags in contenteditable without inserting superfluous tags
    primarykey
    data
    text
    <p>Working with an unordered (or ordered) list in a contenteditable gives me a headache.</p> <p>Whenever I want to end editing the list by pressing <kbd>ENTER</kbd> twice the browser will close the <code>&lt;ul /&gt;</code> but inserts a <code>&lt;p /&gt;</code> (Firefox) or a <code>&lt;div /&gt;</code> (Chrome) tag that contains a <code>&lt;br /&gt;</code>.<br> <strong><a href="http://jsfiddle.net/JZ54G/8/" rel="nofollow noreferrer">Example here</a></strong></p> <p>My goal is to avoid that superfluous <code>&lt;p /&gt;</code> or <code>&lt;div /&gt;</code> and instead just close the <code>&lt;ul /&gt;</code>.<br> I have tried to modify <a href="https://stackoverflow.com/questions/2735672/how-to-change-behavior-of-contenteditable-blocks-after-on-enter-pressed-in-vario#3492423">Tim Down's</a> solution which will prevent the browser to insert <code>&lt;p /&gt;</code> or <code>&lt;div /&gt;</code> when pressing <kbd>ENTER</kbd> and instead inserts a clean <code>&lt;br /&gt;</code> tag.<br> <strong><a href="http://jsfiddle.net/4xyR2/1/" rel="nofollow noreferrer">Example here</a></strong></p> <p>Unfortunately though, when using that solution the <code>&lt;ul /&gt;</code> is never closed by the browser since only <code>&lt;br /&gt;</code> tags are inserted <em>inside</em> the <code>&lt;li /&gt;</code> item.</p> <p>So my question is: </p> <p><strong>How can I actively close the <code>&lt;ul /&gt;</code> by inserting a node or pasting html when pressing enter on the last empty <code>&lt;li /&gt;</code>?</strong></p> <p><strong><em>Update:</strong> In case the question is stll unclear: I am looking for a way to close the <code>&lt;ul /&gt;</code> without inserting <code>&lt;p /&gt;</code> or <code>&lt;div /&gt;</code> tags but just by inserting a good old plain <code>&lt;br /&gt;</code> instead</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload