我在jQuery中有这个小片段
$('.cake_checkboxes').click(function(){
$(this).nextAll('.quantity').first().slideToggle();
});
这是我的HTML
<input id="option-value-24" class="cake_checkboxes" type="checkbox" value="24" name="option[232][]" style="vertical-align: bottom;">
<label for="option-value-24"> Vanilla </label>
<div class="quantity" style="">
<span>
<input class="cake_quantities" type="text" name="quantity_24" size="3">
我想知道如何在slideUp上如何清除下一个cake_quantities输入字段的值...任何想法
答案 0 :(得分:1)
只需在slideToggle
中放置一个回调函数即可 $('.cake_checkboxes').click(function(){
$(this).nextAll('.quantity').first().slideToggle(function() {
$(".cake_quantities").val("");
});
});
答案 1 :(得分:1)
.slideToggle()方法采用可以实现的回调函数。在该函数中,您必须检查实体的当前状态,然后清除输入字段。
答案 2 :(得分:0)
试试这个
$('.cake_checkboxes').click(function(){
var that = $(this);
$(this).nextAll('.quantity').first().slideToggle(function() {
that.nextAll('.quantity').first().find('.cake_quantities').val("");
});
});