Skip to content

Instantly share code, notes, and snippets.

@NANDHINI7390
Created July 18, 2023 09:35
Show Gist options
  • Save NANDHINI7390/ec0d2b661a56f10ec6e8f937d8541403 to your computer and use it in GitHub Desktop.
Save NANDHINI7390/ec0d2b661a56f10ec6e8f937d8541403 to your computer and use it in GitHub Desktop.
Random Dog.api
<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>
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