I am writing a simple editor html. How to implement a text change in the already finished div '? Those. there is a ready-made HTML file, you need to be able to immediately change the text by clicking on a certain block, as devtools does in chrome when “viewing the element code”. The task is not from the standard apparently :) I hope there are ideas)

Closed due to the fact that the essence of the question is incomprehensible by the participants pavel , cheops , aleksandr barakin , Nicolas Chabanovsky 9 Aug '16 at 4:27 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • What have you tried to do? - Mihanik71
  • If you don’t even know where to start this, you shouldn’t do it, it’s a very difficult bike. Look in the direction of ready-made solutions and modify them if you are not satisfied with their functionality. - Dmitry Gvozd
  • I do not see anything inaccurate in the question, I clarified how I could. A comrade with the nickname Maqsood responded to it successfully, simply could not find the same tag, it remains for the small one - to implement sending the modified fragment, I think to use AJAX without hidden forms (using the click function). - John Kindle

1 answer 1

If I understand you correctly, then you need to add the attribute contenteditable For example, this div will work as a textarea:

 <div contenteditable="true"> Здесь текст для редактирования </div> 

To save changes to the text, you can process through jQuery. But one can’t do without contenteditable , you need to send the modified data through hidden forms.

  • Understood, thanks a lot for the answer, but about submitting the form. Isn't an option through AJAX? Just using jQuery to take the content of the block and pass it through the same POST * .php script? Without any hidden forms. - John Kindle
  • @JohnKindle, That's right too! You can get DIV's data in this way $("div").text() and send it where you need it - Maqsood
  • I'll try for sure! Thank you very much! - John Kindle