Change Button

+2 Montaser Qasem · September 15, 2014
Hi all i need code to change a text in <td>(table) and after change it send it back to SQL!
i know how to do it in PHP but i want a change button to do it in Javascript can you help me with the code?
Example:
Some Text     [Button to Edit the text]

Post a Reply

Replies

Oldest  Newest  Rating
+1 Jay Tauron · November 15, 2014
HTML:

<div id="text" contenteditable="false">Dummy text</div>
<button id="edit">Toggle editable</button>


JS (using jQuery):
$('#edit').click(function(){
var $text = $('#text');
var editable = JSON.parse($text.attr('contenteditable'));
$text.attr('contenteditable', (!editable).toString());
});
  • 1

Javascript

107,278 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators