Note that there are some explanatory texts on larger screens.

plurals
  1. POChange table cell from span to input on click
    primarykey
    data
    text
    <p>I am trying to change the table cell from 'span' type to 'input' on click and then back to 'span' on blur but it isn't working as given in here:</p> <p><a href="https://stackoverflow.com/questions/6445223/convert-table-cells-to-text-boxes-with-jquery">Convert table cells to text-boxes with JQuery</a></p> <p>here is the javascript code:</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#assets').click(function () { $('tr td:nth-child(3)').each(function () { var html = $(this).html(); var input = $('&lt;input type="text" /&gt;'); input.val(html); $(this).html(input); }); }); }); &lt;/script&gt; </code></pre> <p>and here is the document body</p> <pre><code>&lt;body&gt; &lt;div id="content"&gt; &lt;table id="assets"&gt; &lt;tr&gt; &lt;td class="asset_name"&gt;&lt;span&gt;Name&lt;/span&gt;&lt;/td&gt; &lt;td class="asset_value"&gt;&lt;span&gt;ast1&lt;/span&gt;&lt;/td&gt; &lt;td class="asset_name"&gt;&lt;span&gt;Location&lt;/span&gt;&lt;/td&gt; &lt;td class="asset_value"&gt;&lt;span&gt;Loc-1&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="asset_name"&gt;&lt;span&gt;Name&lt;/span&gt;&lt;/td&gt; &lt;td class="asset_value"&gt;&lt;span&gt;ast2&lt;/span&gt;&lt;/td&gt; &lt;td class="asset_name"&gt;&lt;span&gt;Location&lt;/span&gt;&lt;/td&gt; &lt;td class="asset_value"&gt;&lt;span&gt;Loc-2&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;​ &lt;/div&gt; &lt;/body&gt; </code></pre> <p>using jQuery 1.7.2</p> <p>What's wrong here ? Please help !</p> <p>Thanks!!</p> <p>Update: only need to change the cells with class='asset_value' and only one cell at a time not all. Also, it should change back to span on blur..</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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