我想要它,所以,如果你選擇的id'defaultone'或'defaulttwo'的圖像之一,那麼具有id'actualone'的圖像更改爲該圖像。我知道我非常接近,但是我有一個小小的錯誤。有人可以幫幫我嗎??Javascript onclick改變id img
<script type="text/javascript">
// Popup window code
function newPopup(url) {
popupWindow = window.open(url,'popUpWindow','height=450,width=600,left=10,top=10,resizable=no,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
function bigimg(x) {
x.style.height="65px";
x.style.width="85px";
x.style.opacity="0.5";
}
function defaultimg(x) {
x.style.height="60px";
x.style.width="80px";
}
function teamback(x) {
document.getElementById("x").src = document.getElementById("defaultone").src;
}
</script>
</head>
<body>
Your Team <img id="defaultone" onmouseover="bigimg(this)" onclick="teamback(this)" onmouseout="defaultimg(this)" src="cowboys.gif"> vs <img id="defaulttwo" onmouseover="bigimg(this)" onclick="teamback(this)" onmouseout="defaultimg(this)" src="giants.gif"><img src="" id="actualone" style="width:85px; height:65px;"><br><br>
<img src="colts.gif"> vs <img src="bears.gif">
</body>
</html>
我在代碼中看不到x元素。 – 2012-08-10 22:52:25
x元素是'this' – 2012-08-10 22:53:58
然後你不應該有雙引號,x.id – 2012-08-10 22:55:04