I'm trying to count the amount of <img>
tags in a div whenever a div is updated. The HTML is simply:
<div id="Description" contenteditable="true"></div>
Whenever the div's contents are changed, I want JQuery to count the the number of images in the div. So I wrote this:
$(document).on('change', '#Description', function(e) {
var filenumber = $('#Description img').length;
alert(filenumber);
});
The problem is that nothing happens. I don't get an alert when I type stuff into the div or insert an image. Am I overlooking something simple? I'm using CKEditor as the rich text editor for the div but I don't think its the problem, however I'm no expert.
Here is a JSFiddle to demo the problem http://jsfiddle.net/jLnLmspn/1/