Given this task, there are several <p> tags, so that the user needs to be able to change them. For example, here's a page with the first element and the second, double-clicked on one of them - an input field appears (instead of text), enter any value, press Enter and that's it: instead of an input field, the text is written by the user! I do not understand at all what I should do and yes, I know that most likely I have complete nonsense written ... But help, please!
HTML
<p onClick="changeTheName()" class="elementClass">First element</p> Js
function changeTheName(){ $('p').dblclick( function () { var element = document.getElementsByClassName('elementClass'); $('p').contents().unwrap(); document.write('<input type="text" id="name">'); $('#name').bind('keypress', function(e) { var code = (e.keyCode ? e.keyCode : e.which); if(code == 13) { var name = document.getElementById('name').value; var inputValue = document.getElementById('name'); inputValue.parentNode.removeChild(inputValue); var d = name; document.write('<p onclick="changeTheName()" class="elementClass">' + d + '</p>'); } }); }); }
contenteditable? - user207618