Multiple id's in a single JavaScript click event

前端 未结 7 630
生来不讨喜
生来不讨喜 2020-12-14 19:23

In JavaScript I am using click event to change chart data. Below is a method for click event.

$(\'#pro1\').click(function () {
            chart.series[0].up         


        
7条回答
  •  死守一世寂寞
    2020-12-14 19:42

    $('#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]
        });
    });
    

提交回复
热议问题