Domanda

How can I (with Javascript) get the new content from a contentEditable DOM element on a page. Would it be as simple as using jQuery in such as way:

$("#content").on("keyup", ".editable", function(e){
  var newText = $(this).text();
  console.log("New text is: "+newText);
});
È stato utile?

Soluzione

The solution was simple as I was (admittedly) being lazy and asking on here. Here's my JSFiddle for those in the future to see: http://jsfiddle.net/ysLPq/. See code below:

$(document).ready(function(){
    $(document).on("keyup", ".editable", function(){
        console.log($(this).text()); 
    });
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top