Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As far as I understood your question, you could try the following, assuming that's how your HTML is structured:</p> <p><strong>HTML Markup</strong>:</p> <pre><code>&lt;table id="mytable"&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Address&lt;/th&gt; &lt;th&gt;Email&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="name"&gt;Tom&lt;/td&gt; &lt;td class="addr"&gt;789&lt;/td&gt; &lt;td class="email"&gt;tom@dot.com&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="name"&gt;Dick&lt;/td&gt; &lt;td class="addr"&gt;456&lt;/td&gt; &lt;td class="email"&gt;dick@dot.com&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="name"&gt;Harry&lt;/td&gt; &lt;td class="addr"&gt;123&lt;/td&gt; &lt;td class="email"&gt;harry@dot.com&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input id="txt1" type="text" /&gt; &lt;input id="txt2" type="text" /&gt; &lt;input id="txt3" type="text" /&gt;​ </code></pre> <p><strong>jQuery</strong>:</p> <pre><code>$(".name").click(function(){ $("#txt1").val($(this).text()); $("#txt2").val($(this).nextAll().eq(0).text()); $("#txt3").val($(this).nextAll().eq(1).text()); });​ $(".addr").click(function(){ $("#txt2").val($(this).text()); $("#txt1").val($(this).prevAll().eq(0).text()); $("#txt3").val($(this).nextAll().eq(0).text()); }); $(".email").click(function(){ $("#txt3").val($(this).text()); $("#txt2").val($(this).prevAll().eq(0).text()); $("#txt1").val($(this).prevAll().eq(1).text()); }); </code></pre> <p><strong>DEMO</strong>: <a href="http://jsfiddle.net/Z9weS/" rel="nofollow">http://jsfiddle.net/Z9weS/</a></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