单击标题时如何获取列名称/索引

时间:2015-06-15 18:20:49

标签: javascript google-visualization

如何在谷歌可视化表中单击相应的列名称/标题时获取列名称(标题)?

http://jsfiddle.net/xj3ww79n/

:- use_module(library(lambda)).

mostcommon_in(E,Xs) :-
   tcount(=(E),Xs,M),
   maplist(Xs+\X^N^(tcount(=(X),Xs,N)),Xs,Counts),
   reduce(\C0^C1^C^(C is max(C0,C1)),Counts,M).

1 个答案:

答案 0 :(得分:1)

在jQuery中

$(".google-visualization-table-th").click(function(e){
    alert("You selected column: " + e.toElement.innerText);
});

在纯JS中

var h = document.getElementsByClassName("google-visualization-table-th");

for (i = 0; i < h.length; i++) {
    h[i].addEventListener("click", function (e) {
        alert("You selected column: " + e.toElement.innerText);
    }, false);
}

在此处查看您的更新小提琴:http://jsfiddle.net/xj3ww79n/4/