javascript - I need to update the text of a paragraph by inline edit -
javascript - I need to update the text of a paragraph by inline edit -
i've tried this
html
<div> <h1>some text here</h1> <p>text area text here</p> </div>
jquery
$(function(){ $('p').on('click', function(e){ e.preventdefault(); var txt = $(this).text(); $(this).parent().append('<textarea>' + txt + '</textarea>'); $(this).remove(); }); });
i need update text of paragraph inline editing. need paragraph new text typed there , remove textarea when click outside of textarea.
thanks
here update fiddle http://jsfiddle.net/99pxz8et/2/
what need hear on alter event new text area , update it
$area.one('focusout', function() { $p.show(); $p.text($area.val()); $area.remove() });
edit: changed .on() .one()
javascript jquery
Comments
Post a Comment