https://codepen.io/rohit357/pen/dmQdZQ
How can i add a button with onclick() function in it to show temperature?
1 Like
something like…
<button class= "btn" id= "temp" onclick= "myFunc(this.id)">
then put the myFunc() in your JS ?
This aint working my friend.
frikkin codepen or my comp is borked… i can’t check the code… but
this.weather … is not valid? … should be… getTemp(this.id)
and you need a new function to handle the clicks?
function getTemp(clicked_id)
{ // set your return stuff here ?
}
remember any variables used in multiple functions should be global
p.s. you don’t really need the id stuff… i just use that to keep track of clicks
Can you please edit the code and paste it here? I dont get what you are saying.
Thankyou very much friend.