2013-05-09 112 views
1

這可能是非常簡單的。我正在尋找添加一個鏈接到另一個頁面。我試圖通過d3添加它。我在JS中添加另一個屬性? Iv嘗試.attr(「src」,「newPage.html」)和.attr(「url」,「newPage.html」),但都不起作用。用d3.js添加一個鏈接到另一個頁面

任何意見,將不勝感激。謝謝。

//JS 
    var newLink = d3.select(".chart") 
     .append("div") 
     .html("Trend Graph") 
     .attr("class", "populationTrend") 


    //CSS 
    .populationTrend{ 
     font-weight:400; 
     margin-top:-15%; 
     cursor:pointer; 
     padding-left:70%; 
     background-color:#039; 
    } 

回答

9

添加一個 「正常」 的鏈接(即錨標記),你可以簡單地做

d3.select(".chart") 
    .append("a") 
    .attr("href", "newPage.html") 
    .html("new page"); 

甚至

d3.select(".chart") 
    .append("div") 
    .html("<a href='newPage.html'>new page</a>"); 
+0

乾杯的人!並感謝快速回復 – Daft 2013-05-09 12:29:04

+0

感謝。非常棒! – scagnetti 2016-03-09 21:09:00

相關問題