<bdo id='kRGQY'></bdo><ul id='kRGQY'></ul>
  1. <i id='kRGQY'><tr id='kRGQY'><dt id='kRGQY'><q id='kRGQY'><span id='kRGQY'><b id='kRGQY'><form id='kRGQY'><ins id='kRGQY'></ins><ul id='kRGQY'></ul><sub id='kRGQY'></sub></form><legend id='kRGQY'></legend><bdo id='kRGQY'><pre id='kRGQY'><center id='kRGQY'></center></pre></bdo></b><th id='kRGQY'></th></span></q></dt></tr></i><div id='kRGQY'><tfoot id='kRGQY'></tfoot><dl id='kRGQY'><fieldset id='kRGQY'></fieldset></dl></div>

      <tfoot id='kRGQY'></tfoot>

    1. <small id='kRGQY'></small><noframes id='kRGQY'>

    2. <legend id='kRGQY'><style id='kRGQY'><dir id='kRGQY'><q id='kRGQY'></q></dir></style></legend>
    3. 单个 JavaScript 点击事件中的多个 id

      时间:2023-09-04

        <tbody id='5v9ZO'></tbody>

        • <i id='5v9ZO'><tr id='5v9ZO'><dt id='5v9ZO'><q id='5v9ZO'><span id='5v9ZO'><b id='5v9ZO'><form id='5v9ZO'><ins id='5v9ZO'></ins><ul id='5v9ZO'></ul><sub id='5v9ZO'></sub></form><legend id='5v9ZO'></legend><bdo id='5v9ZO'><pre id='5v9ZO'><center id='5v9ZO'></center></pre></bdo></b><th id='5v9ZO'></th></span></q></dt></tr></i><div id='5v9ZO'><tfoot id='5v9ZO'></tfoot><dl id='5v9ZO'><fieldset id='5v9ZO'></fieldset></dl></div>
          <tfoot id='5v9ZO'></tfoot>
          • <bdo id='5v9ZO'></bdo><ul id='5v9ZO'></ul>

                <legend id='5v9ZO'><style id='5v9ZO'><dir id='5v9ZO'><q id='5v9ZO'></q></dir></style></legend>

              1. <small id='5v9ZO'></small><noframes id='5v9ZO'>

                本文介绍了单个 JavaScript 点击事件中的多个 id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                在 JavaScript 中,我使用点击事件来更改图表数据.下面是点击事件的方法.

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

                $('#pro1').click(function () {
                            chart.series[0].update({
                                data: pro1
                            });
                        });
                        $('#pro2').click(function () {
                            chart.series[0].update({
                                data: pro2
                            });
                        });
                        $('#pro3').click(function () {
                            chart.series[0].update({
                                data: pro3
                            });
                        });
                

                我需要在一个事件中缩小这三个点击事件,这意味着我想编写一个处理 id 的点击事件.类似于下面的代码.

                I need to minify these three click events in one event, means I want to write one click event which handle the id's. some thing like below code.

                $('#pro'+i).click(function () {
                chart.series[0].update({
                     data: pro+i
                });
                });
                


                我不知道该怎么做.上面的代码不正确,只是我对 JavaScript 的了解不够.


                I don't know how to do it exactly. The above code is not correct, it is just my lack of knowledge of JavaScript.

                推荐答案

                我建议创建一个对象并使用类选择元素,点击元素的 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]
                    });
                });
                

                这篇关于单个 JavaScript 点击事件中的多个 id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:将事件处理程序附加到 twitter 引导弹出窗口中的 下一篇:有没有办法用Javascript跟踪标签的焦点?

                相关文章

                最新文章

                <small id='njrfK'></small><noframes id='njrfK'>

              2. <tfoot id='njrfK'></tfoot>

                  1. <legend id='njrfK'><style id='njrfK'><dir id='njrfK'><q id='njrfK'></q></dir></style></legend>

                    • <bdo id='njrfK'></bdo><ul id='njrfK'></ul>
                  2. <i id='njrfK'><tr id='njrfK'><dt id='njrfK'><q id='njrfK'><span id='njrfK'><b id='njrfK'><form id='njrfK'><ins id='njrfK'></ins><ul id='njrfK'></ul><sub id='njrfK'></sub></form><legend id='njrfK'></legend><bdo id='njrfK'><pre id='njrfK'><center id='njrfK'></center></pre></bdo></b><th id='njrfK'></th></span></q></dt></tr></i><div id='njrfK'><tfoot id='njrfK'></tfoot><dl id='njrfK'><fieldset id='njrfK'></fieldset></dl></div>