Posts

Counter Project

HTML   <button onclick="change()">Start</button> <div> <span value="0" id="value">0</span> </div> JS Script <script type="text/javascript"> function change(){     let count = 0;             let value = document.getElementById('value').innerText;     if(value==0){     count++;     }     else if(value<100){     value++;     count = value;     }     else if(value==100){                 count = 100;     }     else{     count = 0;     }                document.getElementById('value').innerHTML = count;          setTimeout(change, 100);            }         ...

Animation on Scroll using JavaScript AOS Library

Image

Q & A

What is the difference between returning a function on any event and not returning? adding return to a function(), it disables the default behaviour of the browser, it disables the job of submit. Means it will keep you on the same page if the function returns false and you can fill up the value into the field again. If you do not use return with the function() then submit function will perform its job, it will redirect to the next specified page, without caring about the returned result whether it was true or false.

JavaScript PDF Library

Get Presentation PDF Get Ebook PDF

Project- Tip Calculator

<input type="number" name="" id="bill"> <select id="rating"> <option value="0">Select Service Rating</option> <option value="5">Bad</option> <option value="8">Average</option> <option value="10">Good</option> </select> <input type="number" name="" id="no"> <button onclick="getdata()">Get</button> <p id="demo"></p> <script type="text/javascript"> function getdata(){ var bill = document.getElementById('bill').value; var rating = document.getElementById('rating').value; var no = document.getElementById('no').value;     var tip = (bill*(rating/100))*no;     document.getElementById('demo').innerHTML = tip; } </script>