I have following mark up and I am trying to run a javascript function once clicked. So far I haven't faced any success. Plz help -
<div class='color-bar'></div>
<div class='color-bar'></div>
<div class='color-bar'></div>
<div class='color-bar'></div>
var ColorBars = document.getElementsByClassName("color-bar");
var charts = $("#line-container").highcharts();
var series;
var colorIndex = new Array();
for(var i = 0; i < ColorBars.length; i++){
ColorBars[i].onclick = function(){
hideColor(i);
}
}
function hideColor(index){
var charts = $("#line-container").highcharts();
var series = charts.series[index];
if(series.visible){
series.hide();
}
else{
series.show();
}
}
The problem I am having is figuring out which color-bar user has clicked. Is it first one, 2nd or 3rd. Based on this I need to fire the hideColor function.
Thanks a lot. Best regards, jahid