我正在使用JQuery提交表单.表格如下所示
<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>
Run Code Online (Sandbox Code Playgroud)
并且用于捕获表单的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);
});
Run Code Online (Sandbox Code Playgroud)
始终读取product_id,但产品问题始终为null.谁能告诉我为什么会这样?
pet*_*ete 17
.children 只下降一级..find改为使用:
$('#ask-more').on('submit', '.ask-more-form', function () {
var product_id = $(this).children('input[name=product_id]').val();
var product_question = $(this).find('textarea[name="product_question"]').text();
alert(product_question);
//submitQuestion(product_id, product_question);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
46093 次 |
| 最近记录: |