How to make editable div or paragraph by double clicking?
I want to make a simple div which has to become editable when a user double-clicks on it. I wish div to turn into element like text field with cursor to the text where double-click event occurred. Moreover, I want it to turn back into <div> after pressing Enter button. How to hack it?
»Javascript
@ahsafudari
» 1 answer
» 46 views
1 like
Add photos
Gadrawin • 3 weeks ago
Back to top
Gadrawin • 3 weeks ago
Dear anonymous,
There is a simple answer and good way to hack it.
We can handle this by using focus and blur events, I hope you know them.
My example: Suppose you have a div with id=view
»Back to top
[SHARE THIS POST]: The post's archived Spread it to others!
Posted under this donnektish »
This community is about sharing contents such as questions and answers discussing about Javascript and TypeScript, ES5, ES6
66 people joined this donnektish
Related posts/ questions
»
How many ways to assign event handlers in javascript?
» What is eval function in javascript - Where is it used?
» Why some events don't bubble in javascript? need example
» How comes (Microtask queue) while using Promises in js?
» How can you call async from non-async function?
» Are events mouseenter, mouseleave similar to mouseover/mouseout?
» How can I prevent text selection on Mousedown event?
» How to disable copy-paste option using javascript?
» How do default actions work in browser - How to prevent them?
» Whats the effects of shortening form.elements.name to form.name?
» How to make elements like div, table and span support focus/blur?
» What's the logic behind Drag n' Drop algorithm using Javascript?
» What is eval function in javascript - Where is it used?
» Why some events don't bubble in javascript? need example
» How comes (Microtask queue) while using Promises in js?
» How can you call async from non-async function?
» Are events mouseenter, mouseleave similar to mouseover/mouseout?
» How can I prevent text selection on Mousedown event?
» How to disable copy-paste option using javascript?
» How do default actions work in browser - How to prevent them?
» Whats the effects of shortening form.elements.name to form.name?
» How to make elements like div, table and span support focus/blur?
» What's the logic behind Drag n' Drop algorithm using Javascript?
Maintain social distancing, to avoid Covid19