title: Why does this provide me with undefined; jQuery
body: <p>I am using <code>parent()</code> and <code>find()</code> method to access the textarea of the correspoding button.</p>
  
  <p>But I get undefined each time. I have tried it in a jsfiddle, but that fiddle works. Here is the code</p>
  
  <pre><code>&lt;div&gt;
    &lt;textarea id="textarea"&gt;&lt;/textarea&gt;
    &lt;button onclick="commentThis('10')"&gt;Post Comment&lt;/button&gt;
    &lt;button onclick="neverMind('10')"&gt;Never Mind&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>jQuery code is as </p>
  
  <pre><code>function commentThis(postId) {
     var comment = $(this).parent().find("#textarea").val();
     if (comment != "" || comment != null) {
       $.ajax({
         url: "/ajax_requests/post_comment",
         data: "postId=" + postId + "&amp;type=comment&amp;comment=" + 
         comment + "&amp;page=default",
         success: function (result) {
            $(".comments").append(result);
            $("#textarea").val("");
            $("#textarea").css("height", "20px");
         }
       })
     }
  }
  </code></pre>
  
  <p>But it always give me a console error of undefined, saying value cannot be taken from undefine attribute. </p>
  
  <p>You can see the error message here: </p>
  
  <p><img src="https://i.stack.imgur.com/S9RUV.png" alt="enter image description here"></p>
  
  <p>here is the fiddle that I created and which works. <a href="http://jsfiddle.net/afzaal_ahmad_zeeshan/ZBcby/" rel="nofollow noreferrer">http://jsfiddle.net/afzaal_ahmad_zeeshan/ZBcby/</a></p>