I want a specific function to be called when clicking on any p-tag text text. But, it does not work with the text that I create using js The function that I want to run on clicking on p-tag text
$("p").on("rightclick", function () {
if (opened != 1) {
$(this).prop('id', 'editable');
let edit = document.getElementById("edit");
edit.style.display = "flex";
$(this).append(edit);
$("#editable").attr("contenteditable", "true");
$("#editable").attr("spellcheck", "false");
$(this).on("keydown", function(event) {
if (event.keyCode === 13) {
$(this).blur();
}
});
return (opened = 1);
}
});
The function I use to create text
$('#create-text').click(function() {
let textpole = $(this).parents().eq(1)
textpole.append('<p>LoremIpsum</p>');
});