I’m not educated in javascript so I nedd help. Got jquery code like this
$('.player-1').click(function(){
$("#mediaplayer-1").show();
});
$('.player-2').click(function(){
$("#mediaplayer-2").show();
});
$('.player-3').click(function(){
$("#mediaplayer-3").show();
});
.....
So the question is how do write variable (mediaplayer-1, mediaplayer-2….) so you don’t have to write the same lines all the time. I mean increment value of the number of this id
First you need a correct triggering method:
Or make it dynamic by adding
player-triggerclass next toplayer-1and etc:Now you need to cut the unique ID out from your “ID-class” (
player-1). Also note, that Im removing theplayer-trigger..or this wouln’t work:And now lets put all this together with the
show()function:So in this case, your HTML should look kinda like this:
Example: http://jsfiddle.net/hobobne/hLfuH/1/
However, as you probably noticed, it removes the
player-triggerclass, though it looks cool..you might want to do this like this:.. etc
Example 2: http://jsfiddle.net/hobobne/hLfuH/2/