I am trying to explain my problem.
I have a <div contenteditable="true" id="my_editeur> where I defined the keyword" event ", which allows me to add" p "when the user presses" enter ".
It works well, but I would like to define a cursor on this new "p-element", because currently my cursor remains on the first "p" element.
I tried using the jquery focus function, but it seems that we cannot use this function for the 'p elements.
Do you know how I can do this to solve my problem?
Many thanks for your help.
My code is:
$('#my_editeur').keypress(function(e){ if(e.keyCode == 13) { e.preventDefault(); $(this).append('<p ><br /></p>'); } });
source share