【问题标题】:How come that D3.js can select an element that jQuery can't?为什么 D3.js 可以选择 jQuery 不能选择的元素?
【发布时间】:2016-02-12 04:46:15
【问题描述】:
d3.select('#le'+j.toString()).style("background-color", j==i?"#ffffaf":"#dfdfdf");
    //$('#le'+j.toString()).style("background-color", j==i?"#ffffaf":"#dfdfdf");

工作。

//d3.select('#le'+j.toString()).style("background-color", j==i?"#ffffaf":"#dfdfdf");
    $('#le'+j.toString()).style("background-color", j==i?"#ffffaf":"#dfdfdf");

不起作用。我收到以下错误:

【问题讨论】:

  • jQuery 没有.style() 方法。请改用.css() 方法..

标签: javascript jquery select d3.js


【解决方案1】:

必须是

$('#le'+j.toString()).css("background-color", j==i?"#ffffaf":"#dfdfdf");

而不是

$('#le'+j.toString()).style("background-color", j==i?"#ffffaf":"#dfdfdf");

【讨论】:

    猜你喜欢
    • 2011-12-20
    • 2023-03-29
    • 1970-01-01
    • 2015-05-28
    • 1970-01-01
    • 2012-03-29
    • 2012-10-19
    • 2021-07-08
    • 2013-09-05
    相关资源
    最近更新 更多