Note that there are some explanatory texts on larger screens.

plurals
  1. POCopy contents of one field to another using jQuery
    text
    copied!<p>I have a table structure like:</p> <pre><code>&lt;table id='myTable'&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class='name'&gt;Name&lt;/th&gt; &lt;th class='nick-name'&gt;Nick Name&lt;/th&gt; &lt;th class='age'&gt;Age&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class='name'&gt;Ilona&lt;/td&gt; &lt;td class='nick-name'&gt;Baby Doll&lt;/td&gt; &lt;td class='age'&gt;21&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='name'&gt;Sieraa&lt;/td&gt; &lt;td class='nick-name'&gt;&lt;/td&gt; &lt;td class='age'&gt;24&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='name'&gt;Britney&lt;/td&gt; &lt;td class='nick-name'&gt;Blondie&lt;/td&gt; &lt;td class='age'&gt;27&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='name'&gt;Kate&lt;/td&gt; &lt;td class='nick-name'&gt;Night Queen&lt;/td&gt; &lt;td class='age'&gt;19&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='name'&gt;Dani&lt;/td&gt; &lt;td class='nick-name'&gt;&lt;/td&gt; &lt;td class='age'&gt;23&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='name'&gt;Aliee&lt;/td&gt; &lt;td class='nick-name'&gt;&lt;/td&gt; &lt;td class='age'&gt;26&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='name'&gt;Brandi&lt;/td&gt; &lt;td class='nick-name'&gt;&lt;/td&gt; &lt;td class='age'&gt;27&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>As some <strong>Nick Name</strong> fields are empty, I want to display the value of <strong>Name</strong> in <strong>Nick Name</strong> if they are empty.</p> <p>Eg: In <strong>Second Row</strong> of Table Body, The <strong><em>Nick Name</em></strong> field is empty, The <strong><em>Name</em></strong> field contains <strong>Sierra</strong>. So, I want to display <strong>Sierra</strong> in <strong><em>Nick Name</em></strong> field instead of leaving it empty. </p> <p>How can I achieve this using <strong>jQuery</strong> or <strong>JavaScript</strong></p>
 

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