如何使第二个DIV进入点击事件?我现在都把它们都显示出来。我想显示一个,然后当你点击它显示第二个和来回。 我从来没有使用HTML或JavaScript之前,所以忍受着我。DIV到onclick事件
<html>
<head>
<DIV class="container"><HGROUP>
<H1>University of Illinois Hospital and Health Sciences</H1>
<H2>Storage Availability Charts and Graphs</H2></HGROUP><NAV
class="navbar"></div>
<DIV class="container">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Storage', 'Terabytes'],
['Raw', 95],
['Usable', 34],
]);
var options = {
legend: 'none',
pieSliceText: 'label',
title: 'EEI VNX5700',
pieStartAngle: 100,
is3D: true,
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</div>
<DIV class="container">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Unallocated', 'Used', 'Free'],
['Cerner fast pool', 1000, 400],
['General fast pool', 1170, 460],
['Raid', 970, 644]
]);
var options = {
title: 'Unallocated',
vAxis: {title: 'Pools', titleTextStyle: {color: 'red'}}
};
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</div>
<body>
<div id="piechart" style="width: 700px; height: 400px;"></div>
</body>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</head>
</html>
*“?我怎样才能让第二DIV到上点击事件” *我认为你的意思是你想**绑定一个事件处理程序到元素?因为不能将DOM元素转换为事件,所以两者完全不同。如果你想了解事件处理,我建议阅读http://www.quirksmode.org/js/introevents.html。 –
您的html标记不正确。例如,一个[html-page只能有1个'body'-Element](http://www.w3.org/TR/html5/sections.html#the-body-element),通常在head元素之后。 您的代码看起来像您正在使用[Google Charts(Pie Chart)](https://developers.google.com/chart/interactive/docs/gallery/piechart?csw=1)。但是你没有提到它们的使用如何与你的问题一起玩。你能澄清你的问题吗?你对HTML和JavaScript了解多少? – surfmuggle
是的,我正在使用谷歌图表,我试图显示一个图表,然后显示另一个具有更多细节和来回。我不太了解HTML和JavaScript。我在网上学习一个教程,但我没有得到我可以做到这一点的地方。感谢大家的帮助。 –