new to Jquery here. I have four selectors on a click function, see code below, this is because I want the same effect happening on all of them when clicked, instead of making a click function for all four selectors. However, when clicked I want the function to identify which selector was clicked so I can perform an action on one of the selectors, this is why I use id's instead of a class. More precise, I want to set the CSS on a clicked selector to a higher z-index value so it will not be effected by the effect that will be taking place, in this case I want the clicked selector to have an z-index value of 10.
I tried using a if statement, see below, but it's not working, anyone know how to do this?
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
<div id="4"></div>
My jQuery attempt:
$(document).ready(function(e) {
var effect = $("#slide");
$("#1, #2, #3, #4").click(function() {
effect.animate({width: "1100px"}, 200, "easeOutQuint");
$("#2").data('clicked', true);
if ($("#2").data('clicked')) {
$("#2").css("z-index", "10");
}
});
});