title: Referencing this in .querySelector
body: <p>If I use the following to select a certain node</p>
  
  <pre><code>var Link = document.querySelector('table .ctrlcLink');
  </code></pre>
  
  <p>I get the first column value for the column with class ctrlLink, which is what I expected.</p>
  
  <p>However, since I have an onclick event set to an other column in the same table, I would like to get the value of the .ctrlLink column that is on the same row as my clicked element.
  So I tried something like this:</p>
  
  <pre><code>var Link = document.querySelector($(this).closest('tr').children('td.ctrlcLink'));  
  </code></pre>
  
  <p>But then I get </p>
  
  <blockquote>
    <p>"Failed to execute 'querySelector' on 'Document': '[object Object]' is
    not a valid selector."</p>
  </blockquote>
  
  <p>What selector should I use then?</p>
  
  <p>EDIT:
  Maybe I should've added that I need it so that I can use the following afterwards:</p>
  
  <pre><code>var range = document.createRange();  
  range.selectNode(Link);  
  window.getSelection().addRange(range);
  var successful = document.execCommand('copy');
  </code></pre>
  
  <p>EDIT2:
  as suggested, I created a codepen page for this (thanks for that!).:
  <a href="http://codepen.io/whatwhat/pen/JXJjOp" rel="nofollow">http://codepen.io/whatwhat/pen/JXJjOp</a>
  The thing I'm trying to get is that when I click the image in the table, I fetch the text on the same row in the cell next to it and put it in my ctrl-c.
  However, I am unable to get the exact rownumber of the image I click.
  This part doesnt work:</p>
  
  <pre><code>var rowIndex = $(this).index();
  </code></pre>
  
  <p>What would work, how could I get the rownumber.?
  I would then concatenate it changing</p>
  
  <pre><code>var Link = document.querySelector('#docReport tr:nth-child(1) .ctrlcLink');
  </code></pre>
  
  <p>to</p>
  
  <pre><code>var Link = document.querySelector('#docReport tr:nth-child('+rowIndex+') .ctrlcLink'); 
  </code></pre>
  
  <p>Or can I resolve this in another way?</p>
  
  <p>EDIT3:
  I eventually got what I needed like this:
  <a href="http://codepen.io/whatwhat/pen/GZEgKK" rel="nofollow">http://codepen.io/whatwhat/pen/GZEgKK</a></p>