how can i retrieve which one of my selection is my “current” target?
I would like to have different variables inside this function.
$('#header a, #nav a').click(function (event) {
// if is $('#header a') do this
// if is $('#nav a') do that
});
thiswill refer to the actual DOM element, and so you can checktagNameorclassName, or look for$(this).parents('#header').Live example
Off-topic: I agree with Felix and melaos that if you’re really doing things that different, refactoring into separate handlers (perhaps calling common functions) is probably the better way to go…