divおよびonclickイベントは、ラベルとスパンをラップします。 IEでは、ラベルがクリックされるとイベントが2回トリガーされ、スパンがクリックされるとイベントが1回トリガーされます。これは他のブラウザでは起こりません。onclickイベントはIEでは2回、FFまたはChromeでは2回トリガーされません。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="application/javascript">
function showHide(id) {
var node = document.getElementById(id);
if (node.style.display != "none")
node.style.display = 'none';
else
node.style.display = 'block';
}
</script>
</head>
<body>
<div onclick="showHide('expandDiv')">
<label id="outLabel" for="outText">Label</label>
<span id="outText">This is an example of an</span>
</div>
<div id="expandDiv" style="display:block">
<p>Expanded Div</p>
</div>
</body>
</html>
はあなたを入れてみてください中括弧で囲まれた状態 – winresh24
これで問題は解決されませんでした。 – John
スパンのラベルがあるのはなぜですか? – nnnnnn