使用按钮,我试图让图像在第一次点击时移动到页面的右上角,并在第二次点击时回到它的原始位置。任何进一步的点击都会简单地继续这个循环,因为我是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>
这是完美的。非常感谢! –