I have the following code...
$('#item_' + code + ' .delete').hide();
$('#item_' + code + ' .deleting').show();
$('#item_' + code).slideUp(400, function() {
$(this).remove();
$('#top .message').html('Item has been deleted');
});
I want to save the selector I'm using in a variable and use it to perform operation instead of searching the DOM everytime.
So I save the selector like this...
var saved = $('#item_' + code);
But how do I change the rest of the code? I'm not very familiar with jQuery, hence wondering how this can be done. Will this work...
$(saved).(' .delete').hide();
$(saved).(' .deleting').hide();
$(saved).slideUp(400, function() {
$(this).remove();
$('#top .message').html('Item has been deleted');
});
I'll add another alternative
$('.delete', saved).hide();
$('.deleting', saved).show()
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With