0

when I click and blur div, an other div is create in last, but when I blur div what just is add, javascript not working, please tell me, why? and how fix.

Thanks for advance. Sample is: http://jsfiddle.net/a4QNB/420/

js:

var contents = $('.changeable1').html();
$('.changeable1').blur(function() {
        $('#addItem').before('<div class=\"changeable1\" contenteditable=\"true\"> Click this div to edit it </div>');
});
guradio
  • 15,524
  • 4
  • 36
  • 57
Chung Do
  • 79
  • 9

1 Answers1

1

The new div is getting dynamically added, so try to delegate the event.

var contents = $('.changeable1').html();
$('body').on('blur','.changeable1',function() {
        $('#addItem').before('<div class="changeable1" contenteditable="true"> Click this div to add an other div </div>');
});

Note: You are using jquery 1.6. on is not available with this version

JSFIDDLE

brk
  • 48,835
  • 10
  • 56
  • 78