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 that I use in a variable and use it to perform an operation instead of finding the DOM every time.
So, I keep the selector like this ...
var saved = $('#item_' + code);
But how do I change the rest of the code? I am not very familiar with jQuery, so I wonder how this can be done. Will it work ...
$(saved).(' .delete').hide(); $(saved).(' .deleting').hide(); $(saved).slideUp(400, function() { $(this).remove(); $('#top .message').html('Item has been deleted'); });
jquery jquery-selectors
vikmalhotra
source share