使用按钮,我试图让图像在第一次点击时移动到页面的右上角,并在第二次点击时回到原来的位置。任何进一步的点击都会继续循环,因为我是 JS 新手,我不确定要使用什么 addEventListeners。提前致谢
HTML:
<div id="task2" class="task">
<h2>Task 2</h2>
<!-- image courtesy Google Chrome -->
<img src="media/chrome.png" alt="Chrome Browser" id="chrome_browser">
<ol>
<li>First click: Move the Chrome icon to the top, right corner of the page.</li>
<li>Second click: Move the Chrome icon back to it's original spot.</li>
<li>Further clicks: Continue the cycle.</li>
</ol>
<input type="button" value="Move" id="task2control">
</div>