কম্পিউটার টিউটোরিয়াল

জাভাস্ক্রিপ্টে clearTimeout() ফাংশনের ভূমিকা

আপনি যদি setTimeout() ফাংশন ব্যবহার করে টাইম সেট করে থাকেন, তবে আপনি জাভাস্ক্রিপ্ট clearTimeout() ফাংশন ব্যবহার করে সেটি ক্লিয়ার করতে পারেন।

উদাহরণ

নিচের কোডটি চালিয়ে জাভাস্ক্রিপ্টে clearTimeout() ফাংশন বাস্তবায়ন শিখুন:

<html>    <head>       <title>JavaScript Animation</title>       <script>          <!--             var imgObj = null;             var animate ;             function init() {                imgObj = document.getElementById('myImage');                imgObj.style.position= 'relative';                imgObj.style.left = '0px';             }             function moveRight() {                imgObj.style.left = parseInt(imgObj.style.left) + 10 + 'px';                animate = setTimeout(moveRight,20); // call moveRight in 20msec             }             function stop() {                clearTimeout(animate);                imgObj.style.left = '0px';             }             window.onload =init;          //-->       </script>    </head>    <body>       <form>          <img id = "myImage" src = "/images/html.gif" />          <p>Click the buttons below to handle animation</p>          <input type = "button" value = "Start" onclick = "moveRight();" />          <input type="button" value="Stop" onclick="stop();" />       </form>    </body> </html>

  1. জাভাস্ক্রিপ্টে screenX মাউস ইভেন্টের ভূমিকা কী?

  2. জাভাস্ক্রিপ্টে parseFloat() মেথডের ভূমিকা কী?

  3. জাভাস্ক্রিপ্টে parseInt() মেথডের ভূমিকা কী?

  4. জাভাস্ক্রিপ্টে apply() ফাংশনের ব্যবহার