(Im using the before()
function from jquery to append a new <p>
element to a div layer.
$('#AddParagraphButton').click(function() {
$('#TheLayer').before('<p contentEditable='true'>Some text...</p>');
});
here I have set keypress
function to insert <br>
tag.
$('p').keypress(function(e){
if(e.which == 13){
e.preventDefault();
document.execCommand('insertHTML', false, '<br/>');
}
});
this works fine(br tag inserts) until the append function is called and a new <p>
is added. How do I get livequery to unbind the keypress event and bind again?
EDIT: the <p>
tags have the contentEditable property. Im doing this because the <br>
tags are wrapped in divs and I only want <br>
tags