正如你可能会看到下面,我创建了函数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