dongtiao2105 2015-07-15 10:14
浏览 363

如何创建一个从HTML中删除程序代码的按钮?

Here is an example of what I'm trying to do.

Here is the code.

var data = {
labels: ["January", "February"],
datasets: [
    {
        label: "My First dataset",
        fillColor: "rgba(220,220,220,0.2)",
        strokeColor: "rgba(220,220,220,1)",
        pointColor: "rgba(220,220,220,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(220,220,220,1)",
        data: [65, 59, 80, 81, 56, 55, 40]
    },
    {
        label: "My Second dataset",
        fillColor: "rgba(151,187,205,0.2)",
        strokeColor: "rgba(151,187,205,1)",
        pointColor: "rgba(151,187,205,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(151,187,205,1)",
        data: [28, 48, 40, 19, 86, 27, 90]
    }
]
};

I would like to create two buttons that act as toggles. Each button would correspond to one of the two data sets. So pressing on button one would either remove or bring back the code for the first dataset and same thing for button 2 with the second dataset.

Is this possible?

  • 写回答

1条回答 默认 最新

  • doudanglang5826 2015-07-15 10:27
    关注

    You want to call a function on your button that takes as parameter the name of your button. This is easily achievable with jQuery, and depending on the name of the button you change the properties of whichever element you want to change.

    The same function will be usable for the two buttons and they'll act as toggle since they'll react differently depending on the button name.

    评论

报告相同问题?

悬赏问题

  • ¥15 网络科学导论,网络控制
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)