This plug-in makes any DOM content editable and displays a Save button underneath the content. A SaveHandler can be specified that is fired when the Save button is clicked. You can press ESC while in the editable area to abort editing without firing the SaveHandler.

jQuery.fn.contentEditable = function(options)


The options parameter can be a map of any of these properties (default values are shown):

var def = { editClass: null, saveText: "Save", saveHandler: null };

The CSS class for the edited element. Optional. If not specified an Azure background is used.

The text of the save button. "Save" by default. The Save button also assigns an implicit class="editableButton" to allow you to override styling of the button.

Event handler when the Save button is clicked.


$("#divMessage").contentEditable( saveText: "Update Comment", editClass: "contenteditable", // css class for edited text saveHandler: function(e) { // this is content element edited alert( $(this).html() ); // or use .text() return true; // true to stop editing, false to keep editing });