我想你將不得不創建「編輯表單」爲模板或contentEditable去
如果用「Edit Form」作爲模板;
<span style="display:none;" id="editForm_template">
<form action="control.php" method="post">
<textarea class="templateTextarea"></textarea>
</form>
</span>
與jQuery
<script>
$(document).ready(function(e){
////////Make the edit button as a class.
$(document).on('click', '.editButton', function(){
//Get the parent of both the edit button and the paragraph
var parent = $(this).parent('.parentOfBoth');
var editFormTemplate = $('#editForm_template').html();
var currentTextInParagraph = $(parent).find('.paragraphTobeEditted');
$('.templateTextarea').val(currentTextInParagraph);
$(parent).slideUp('fast',function(){
// Append the template after the parent of both the paragraph and edit button have been hidden (slideUp)
$(parent).after(editFormTemplate);
});
});
});
</script>
在HTML5任何元素都可以編輯
<!DOCTYPE html>
<html>
<body>
<div contentEditable="true">
This text can be edited by the user.
</div>
</body>
</html>
請添加相關的HTML以及 – Dhiraj
如何使用'contenteditable'屬性? – Terry