javascript - Get Edited TD values in jQuery


I have an HTML table whose span is populed by PHP variables. The table is showing up pretty well, showing the data present in the database. The following is the table row, which is wrapped inside a PHP while loop.

<table id="sample_editable_1" role="grid" aria-describedby="sample_editable_1_info">
 <tr role="row" >
  <td contenteditable="false" >
   <span > </span>
  <td contenteditable="false">
   <span ><?php echo $itid1; ?></span>
  <td contenteditable="false">
   <span ><?php echo $name1; ?></span>
  <td contenteditable="false">
   <span > <?php echo $price1; ?></span>
  <td contenteditable="false">
   <span ><?php echo $qty1; ?></span>
   <button value="edit" href="javascript:;"> Edit </button>
   <button href="javascript:;"> Delete </button>

The following is jQuery function I am using to pull the Data.

$('#sample_editable_1').on('click', '.pr_edit', function() {
  var currentTD = $(this).parents('tr').find('td');
  $.each(currentTD, function() {
    $(this).prop('contenteditable', true);

  var ino = $(this).closest('tr').find("span.itid").text();
  var iname = $(this).closest('tr').find("").text();
  var iprice = $(this).closest('tr').find("span.price").text();
  var iqty = $(this).closest('tr').find("span.qty").text();

However, I am not able to retrieve the values from the fields that are edited. The rest of the TR cells are Okay. How do I retrieve modified values from the Table cells I have edited?


I am able to obtain values that are from unedited TR cells. The jQuery selectors are correct.

People are also looking for solutions to the problem: php - Update data on a page without refreshing


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.