I am attempting to establish a connection between various elements in order for a specific class element to trigger an action on another specific class element (for example, when .ph5
is clicked, .art5
should become visible)
Here is what I have developed so far:
var back = [$(".art1"), $(".art2"), $(".art3"), $(".art4"), $(".art5"), $(".art6"), $(".art7"), $(".art8"), $(".art9")];
var front = [$(".ph1"), $(".ph2"), $(".ph3"), $(".ph4"), $(".ph5"), $(".ph6"), $(".ph7"), $(".ph8"), $(".ph9")];
$('front').click(function(e) {
var clicked = $(e.clicked);
for (var i = 0; back.length; i++) {
if (clicked.is(front[i])) {
back[i].show();
}
}
});
Unfortunately, this implementation does not seem to be functioning as expected. Could there be an error in my code, or is there a more effective method of "linking" multiple classes together?