title: TypeError: text.value is undefined
body: <p>Hi I'm trying to get selected value of a input when input is focused with tab. This is my code,</p>
  
  <p>HTML,</p>
  
  <pre><code>&lt;input id='texteb' type="text" value=''/&gt;
  &lt;button&gt;
    click
  &lt;/button&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>$(function(){
      $(window).on('keyup', function (e) {
      var focused = $(':focus');
  
      if (e.which === 9){
              var text = focused;
              var t = text.value.substring(text.selectionStart, text.selectionEnd - text.selectionStart);
              alert(t);
      }        
    });
  });
  </code></pre>
  
  <p>But I'm getting this error,</p>
  
  <blockquote>
    <p>TypeError: text.value is undefined</p>
  </blockquote>
  
  <p>This is <a href="https://jsfiddle.net/vimuths/7fzk6tpo/10/" rel="nofollow noreferrer">Jsfiddle</a> for it.</p>
  
  <p>With answers this issue can be solved with .val() but <strong>selectionStart</strong> seems to be giving undef</p>