How to make an element's content editable with JavaScript (or jQuery)

Viewed 62492

How would I make it so the content of an element could be made editable through native JavaScript (DOM) and/or jQuery?

6 Answers

All we have to do is set the contenteditable attribute on nearly any HTML element to make it editable.

Here's a simple example which creates a element whose contents the user can edit.

<div contenteditable="true">
  This text can be edited by the user.
</div>
Related