title: how to write js function to get input value when click button
body: <p>i have several class="items" that include input and button, and i want to click button and identify whether siblings input has value or not.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function onClick(elem) {
    var $this = elem.tagName;
    var val = $this.siblings('input[type=text]').val();
    if (val == '') {
      console.log('no input');
    } else {
      console.log(val);
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="items"&gt;
    &lt;input type="" name="" id="keywordSearch1" placeholder=""&gt;
    &lt;button onclick="onClick()"&gt;button1&lt;/button&gt;
  &lt;/div&gt;
  &lt;div class="items"&gt;
    &lt;input type="" name="" id="keywordSearch2" placeholder=""&gt;
    &lt;button onclick="onClick()"&gt;button2&lt;/button&gt;
  &lt;/div&gt;
  &lt;div class="items"&gt;
    &lt;input type="" name="" id="keywordSearch3" placeholder=""&gt;
    &lt;button onclick="onClick()"&gt;button3&lt;/button&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>