Created
July 18, 2023 09:35
-
-
Save NANDHINI7390/ec0d2b661a56f10ec6e8f937d8541403 to your computer and use it in GitHub Desktop.
Random Dog.api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="baby"><img src=" https://dog.ceo/api/breeds/image/random " alt="babies" height="100" width="100"></div> | |
<br> | |
<button id="images" style="color:green; background-color: white">change me🙂</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const babyImg=document.getElementById('baby') | |
const imgChange=document.getElementById('images') | |
const changeImg=()=>{ | |
fetch(' https://dog.ceo/api/breeds/image/random ') | |
.then(response=>response.json()) | |
.then(json=>{ | |
babyImg.innerHTML=`<img src='${json.message}'height="300" width="300"/>` | |
}) | |
} | |
imgChange.onclick=()=>changeImg() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment