开发者

Using contenteditable with jquery

开发者 https://www.devze.com 2023-03-10 14:16 出处:网络
I have a div <div id=\"content_x\" class=\"something\" contenteditable=\"true\"> In fact I have several of these, hence the class name. When class something is edited, I get the id using some

I have a div

<div id="content_x" class="something" contenteditable="true">

In fact I have several of these, hence the class name. When class something is edited, I get the id using some regex magic id = $(this).attr('id');

How can I check that the content of this textarea has changed, because I want to send this via regex.

I can get the old value, but how do I get the old value?

$('.something').click(function() {
  $('.something').change();

});

I'v开发者_运维技巧e also heard of this plugin: http://valums.com/edit-in-place/ however this places buttons in your divs. I want the new value when the user clicks away from the div.


Is this what you are looking for?

var contentWhenPageLoaded = document.getElementById("content_x").innerHTML;

//Then you can check if the content has changed like this:
if(contentWhenPageLoaded != document.getElementById("content_x").innerHTML) {
  alert("content has changed!");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消