This is my first post … so here it goes!
I’m trying to get the value of a text area upon a button click – one of 2 -> it registers the button clicks and triggers my php script fine but won’t register the textarea contents, it shows up as empty. I’ve used .val, .text and .html. I’m not sure what’s wrong …
HTML:
<div> <textarea id="comments_box" placeholder="Reasoning for your decision ..." style="width:99%" ></textarea> </div>
Jquery
$("#reject").click(function(){
var comments = $("#comments_box").val();
alert(comments);
});
$("#accept").click(function(){
var comments = $("#comments_box").val();
alert(comments);
});
Thanks in advance!
Instead of using
.val;use.val();that will fix your problem. Please, it’s also important that you constantly check the browser console for javascript syntax errors.Just to add something, if your textarea is in DOM, please use the following: