forum

Home / DeveloperSection / Forums / How to Linking different elements together

How to Linking different elements together

Anonymous User 1791 20-Jan-2015

I am trying to link several different elements together so that one specific class element can activate an action on another specific class element (for instance, if .ph5 is clicked, .art5 will be visible)

This is what I have 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 doesn't seem to work for me. Is there something wrong with my code and/or is there a better way to "link" multiple classes together?


Updated on 20-Jan-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By