title: jQuery equivalent of document.getElementById().size
body: <p>I am looking into jQuery equivalent of following HTML DOM method in order to find size of an text box element:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  Name: &lt;input type="text" id="myText"&gt;
  
  &lt;p&gt;Click the button to set the width of the text field.&lt;/p&gt;
  
  &lt;button onclick="myFunction()"&gt;Try it&lt;/button&gt;
  
  &lt;script&gt;
  function myFunction() {
    alert(document.getElementById("myText").size);
    document.getElementById("myText").size = "50";
    alert(document.getElementById("myText").size);
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Running above HTML shows two alert boxes with output 20 and 50 respectively. 20 is displayed as the default textbox size and 50 is displayed after the size is reset to 50. I need to read this size attribute through jQuery. I tried to switch following code line in above snippet with possible jQuery way but it does not shows expected output:
  Current:</p>
  
  <pre><code>alert(document.getElementById("myText").size);
  </code></pre>
  
  <p>Changed to</p>
  
  <pre><code>alert($("myText").val().length);  //shows length of the value inside textbox.
  
  alert($("myText").length); // shows 1 in the output and its expected because its jQuery's way of showing number of elements not its size.
  
  alert($("myText").size()); // shows 1 in the output. This is equivalent to the length property. using size() is jQuery's preffered way as using length is deprecated.
  </code></pre>
  
  <p>I tried jquery <a href="https://api.jquery.com/size/" rel="nofollow noreferrer">docs</a> but could not be able to find what I am looking for. Related stackoverflow questions talk about finding length of the value inside a textbox but I am looking for the size of the textbox. My use case needs to find out size of the textbox on the UI screen in order to determine position of a tooltip box and other popup windows.</p>