javascript - Allowing user to change the text of a div -


this query in of questions. got no solution reposting question , can solve dilemma.

i have div.i want div contents editabe. want onlick of button div should turn text box , allow user change contents of div. prefer avoid jquery.

http://jsfiddle.net/qbxcw/11/

html

<div id="main">     <div id="allowedit">click button edit text         <input type="button" value="clk me" onclick="changetext(this)" />     </div>   <div> 

javascript

changetext = function (e) {        src=(e.parentnode);      src.outerhtml="<div><input +"+"name=input"+"></div>";      } 

you can use html attribute contenteditable

<div contenteditable="true">   text can edited user. </div> 

Comments