正如你可能會看到下面,我創建了函數getChart(); 它在自己調用時工作,但是當我將它包裝到$(document).ready(function(){...})時不顯示圖表; 我還附上了文件.. 任何幫助,高度重視和感激..感謝名單..谷歌圖形不工作與jQuery按鈕功能
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Visualization API Sample</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function getChart(){
google.load('visualization', '1', {packages: ['corechart']});
function drawVisualization() {
// Populate the data table.
var dataTable = google.visualization.arrayToDataTable([
['Mon', 20, 28, 38, 45],
['Fri', 68, 66, 22, 15]
// Treat first row as data as well.
], true);
// Draw the chart.
var chart = new google.visualization.CandlestickChart(document.getElementById('visualization'));
chart.draw(dataTable, {legend:'none', width:600, height:400});
}
google.setOnLoadCallback(drawVisualization);
}
$(document).ready(function(){
$('#idbutton').click(function(){
getChart();
});
});
</script>
</head>
<body>
<input id="idbutton" type="button" value="button" />
<div id="visualization"></div>
</body>
</html>
'getChart()'返回一個字符串嗎?做alert(getChart());'告訴我們輸出。 – 2012-08-02 16:52:31
如果我不得不猜測,我猜「這個」並不是指向你想要的地方,但說實話,這裏沒有太多的代碼。 – tsiki 2012-08-02 18:09:17
我附上了上面的代碼..謝謝.. – MegaByteMe 2012-08-02 19:55:35