Multiple id's in a single JavaScript click event
Try this:
var that = this;
$('#pro1,#pro2,#pro3').click(function () {
chart.series[0].update({
data: that[$(this).attr('id')];
});
});
I would suggest creating an object and selecting the elements using classes, id
of the clicked element retrieves value of the corresponding property of the helper object:
var pros = {
pro1: '...',
pro2: '...'
};
$('.pros').click(function () {
chart.series[0].update({
data: pros[this.id]
});
});
$('#pro1,#pro2,#pro3').click(function () {
chart.series[0].update({
data: $(this).attr('id');
});
});
Updated code
$('#pro1,#pro2,#pro3').click(function () {
chart.series[0].update({
data: window[this.id]
});
});