A simple JavaScript project to demonstrate how to swap two images when a button is clicked. Great for beginners learning DOM manipulation!
- JavaScript
- HTML
- CSS
- Pure JavaScript (no libraries)
- Easy to understand and customize
- Works on all modern browsers
Two <img>
elements are targeted via their id
s. A button triggers the swap by switching the src
attributes of the two images.
image-swap/ ├── index.html ├── script.js ├── image1.jpg ├── image2.jpg └── README.md
-
Clone the repo:
git clone https://github.com/shravanithouta108/2-images-swap.git cd image-swap
-
Add your own images: Replace image1.jpg and image2.jpg with your own images in the root directory.
-
Open in browser: Open index.html in your browser.
MIT License. Feel free to use, modify, and share.