我創建了一個簡單的事件腳本,它在點擊按鈕時更改圖像。但不幸的是不改變,請幫助!提前致謝。事件在Javascript中無法正常工作
錯誤:我也沒有收到任何錯誤消息,只是它沒有改變圖像。
<html>
<head>
<title>Events Practise</title>
<style>
#imtest{
width:100px;
height:150px;
}
</style>
</head>
<body>
<h4> This a practise page of Events and event handlers </h4>
<p> Hi this the practise page that changes the Html and Css contents in the page by Using the JavaScript </p>
<img id="imtest" src="marni.jpg" alt="Image corrupted">
<button onclick="eventtest()">Change Image</button>
<script>
function eventtest()
{
var imt = document.getElementById("imtest");
imt.onclick = change;
}
function change()
{
var imtchng = document.getElementById("imtest");
imtchng.src = "marni1.png";
}
</script>
</body>
謝謝您的澄清!現在我明白了我犯的錯誤:-) –
@SatishMarni如果有幫助,請接受我已經接受的 – Ramanlfc
的回答,但它表明「我沒有15個聲望點,所以選票被記錄下來」這樣的一些事情! ! :-) –