Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery, Javascript button
    primarykey
    data
    text
    <p>Sorry for the vague title, couldn't think of how to title my question. So I've made a html/css table wherein I placed an edit button for each row. Pressing the button would transform a certain text field into a text-input field there by allowing the user to edit the data inside; at the same time the edit button then transforms to save button. After editing , the user then would press the save button and the text-input field would then revert back into a text field and the save button back to an edit button. But it's not entirely working</p> <p>This is my problem, after editing the data inside, upon pressing the save button, the data inside is deleted and replaced with: <code>&lt;input type= and outside the text-input field is: " /&gt;</code> and the save button remains as is, a "SAVE" button and not back to an "EDIT" button</p> <p>here's the script:</p> <pre><code>$(document).ready(function () { // listen for email edit button click $("button#edit").on('click', function () { // get email inline to this edit button var email = $(this).parent().siblings('td.email').html(); alert(email); // change button from edit to save $(this).attr('id', 'save-email').html('SAVE'); // change email display to input field $(this).parent().siblings('td.email').html('&lt;input type="text" id="user-email" value="' + email + '" /&gt;'); }); // listen for email save button click $("button#save-email").on('click', function () { // get new email inline to this save button var newEmail = $(this).parents('tr').find($('input#user-email')).val(); alert(newEmail); // change input field back to display $(this).parent().siblings('td.email').html(email); // change button from save to edit $(this).attr('id', 'edit').html('EDIT'); }); }); </code></pre> <p>sorry for the wall of text.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload