on slideup can I clear out the input text field in jQuery?
I have this little snippet in jQuery
$('.cake_checkboxes').click(function(){
$(this).nextAll('.quantity').first().slideToggle();
});
here is my 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 开发者_如何学Pythonclass="quantity" style="">
<span>
<input class="cake_quantities" type="text" name="quantity_24" size="3">
and I was wondering how to on slideUp how can i clear the value of the next cake_quantities input field...any ideas
Simply place a callback function inside the slideToggle
$('.cake_checkboxes').click(function(){
$(this).nextAll('.quantity').first().slideToggle(function() {
$(".cake_quantities").val("");
});
});
The .slideToggle() method takes a callback function that you can implement. In that function you have to check the current state of the entity and clear your input fields then.
try this
$('.cake_checkboxes').click(function(){
var that = $(this);
$(this).nextAll('.quantity').first().slideToggle(function() {
that.nextAll('.quantity').first().find('.cake_quantities').val("");
});
});
精彩评论