Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Other solution can be something like below,</p> <p>You need two changes,</p> <ol> <li><p>Try to bind the click event on the span, not on the td. Since binding click on td will also get trigger when you click the edit or cancel button, although you could also add the preventDefault.</p></li> <li><p>You had not taken the value of the input field rather you are grabbing the element.</p></li> </ol> <p>So your code should look something like this </p> <pre><code>jQuery(document).ready(function() { jQuery('td span:nth-child(2)').hide(); jQuery("table.gs tbody tr td:nth-child(2) .label").click(function() { jQuery('img[alt="cancelCost"]').trigger('click'); jQuery(this).parent().find("span:nth-child(1)").hide(); jQuery(this).parent().find("span:nth-child(2)").show(); var value = jQuery.trim(jQuery(this).parent().text()); jQuery(this).parent().find("input").val(value); }); jQuery('img[alt="editCost"]').click(function() { var value = jQuery(this).siblings("input[type=text]").val(); jQuery(this).parent().parent().find("span.label").text(value).show(); jQuery(this).parent().hide(1); }); jQuery('img[alt="cancelCost"]').click(function() { jQuery(this).parent().hide(1); jQuery(this).parent().parent().find("span.label").show(); }); }); </code></pre> <p>Try this fiddle <a href="http://jsfiddle.net/jCHWy/32/" rel="nofollow">http://jsfiddle.net/jCHWy/32/</a></p> <p>You are also not reverting back the value you had already before the edit. And once cancel is clicked the span is blank. Modified this also.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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