How can I create something such as:
- there is some text
- I click on it
- It transforms into an input that contains the text I clicked on.
How about something like this
HTML
<div onclick="transform(this)">Some text here</div>
Javascript
function transform(obj)
{
obj.innerHTML = "<input type='text' value='" + obj.innerHTML + "' />";
}
Hope I've understood your question correctly.
<a href="#" onclick="var input = document.createElement('input'); input.setAttribute('value', this.firstChild.nodeValue); this.parentNode.replaceChild(input, this);">here is some text</a>. Click it.
Instead of <a>
you could also use <span>
or <div>
whatever you feel like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With