$('#postLsit').on('click','[id^=edit_]', function(event){ var messageId = $(this).attr('id'); messageId = messageId.replace(/edit_/g, ''); messageId = parseInt(messageId); tinymce.execCommand("mceRemoveEditor", true, messageId); startEditor(messageId); tinymce.get(messageId).setContent($("#post_message_"+messageId).html()); $("#editSection_"+messageId).removeClass('hidden'); $("#button_section_"+messageId).addClass('hidden'); });