+ 2

How can i make a simple web page that gathers the amount of time a button is pressed?

I have a like button in my web page and I want that when user clicks it it increments the value of the number of likes by 1 and when again press it it reduce it by 1.

4th Nov 2016, 2:44 PM
Apurav Mahajan
Apurav Mahajan - avatar
3 ответов
+ 3
that sounds interesting there are widgets for these. is it a local file on the project folder. if yes then following is the best simple thing webpage you can do. it s not practical program as <button> Like </butto> <div id=countedlikes>No Likes Given </div> <script> var likebtn=document.querySelector("button"), countedlikes = 0 , countedlikedisplay = document.getElementById("countedlikes") ; likebtn.onclick = likeonce(); function likeonc(){ countedlikes++; countedlikedisplay.innerHTML=countedlikes+' likes'.} </script> however you close the browser tab refresh likes are gone. to store them do this. document.setcookie(likes : countedlikes); and at begging add document.onload=updatelikes(); function updatelikes(){ countedlikes=document.cookie.likes likeonce();} but you run a cleaner it will clean the likes even browsers do that automatically and even they expire automatically and making you not like so my answer is to use widgets from good sources.
5th Nov 2016, 3:24 PM
Sandeep Chatterjee
6th Nov 2016, 3:37 AM
Apurav Mahajan
Apurav Mahajan - avatar
+ 2
thanx sandeep
6th Nov 2016, 3:31 AM
Apurav Mahajan
Apurav Mahajan - avatar