1. 程式人生 > >JS練習:切換圖片

JS練習:切換圖片

程式碼:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <script>
        function changeImg() {
            var img = document.getElementById("img1");
            img.src = "https://i03piccdn.sogoucdn.com/1ce429cb207df745
"; } </script> </head> <body> <input type="button" value="點選切換圖片" onclick="changeImg()"/> <br/> <img src="https://i01piccdn.sogoucdn.com/d5d909ee8ce5249d" id="img1"/> </body> </html>
View Code