का उपयोग कर TextArea प्राप्त करना मैं JQuery का उपयोग कर एक फॉर्म सबमिट कर रहा हूं।JQuery
$('#ask-more').on('submit', '.ask-more-form', function() {
var product_id = $(this).children('input[name=product_id]').val();
var product_question = $(this).children('textarea[name="product_question"]').text();
alert(product_question);
//submitQuestion(product_id, product_question);
});
product_id हमेशा पढ़ने के लिए है, लेकिन सवाल यह है कि उत्पाद हमेशा रिक्त है: नीचे
<form class="ask-more-form">
<div class="product_info_2">
<textarea name="product_question" class="textbox" placeholder="Ask You Question Here"></textarea>
</div>
<input type="hidden" name="product_id" value="1" id="product_id">
<a href="#" class="whiteButton submit" id="ask-more-submit-button">Ask Question</a>
</form>
और JQuery को पकड़ने के लिए की तरह फार्म इस तरह दिखता है प्रपत्र लग रहा है। क्या कोई मुझे बता सकता है कि यह क्यों हो रहा है?
वैल() का उपयोग करने का संयोजन है और –
व्यक्तिगत रूप से, मैं '.val()' का उपयोग करता हूं, लेकिन '.text()' 'textarea 'के लिए काम करेगा। डेमो के लिए http://jsfiddle.net/kfD7b/ देखें। – pete