The most viewed posts

About Desktop Icons in Windows Computer

How to clean up Windows Computer

Driver Booster

CCleaner

Advanced System Care

Myanmar font and keyboard for Windows

Registry Reviver

How to make a computer secure and run faster

some (JavaScript Array Method)

Terms and Conditions

The most viewed items

Desktop Hard Disk

HP ProBook 430

Dell Inspiron 5559

External Hard Disk

SONY Playstation Portable

Laptop RAM

Laptop

ZilaStar ICT Jun 15 2022, 09:33:58
Category : JavaScript Tutorials

JS Arrow Function

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<button id = "btn1">Try Now</button>
<p id = "demo1"></p>

<button id = "btn2">Try Now</button>
<p id = "demo2"></p>

<script>
var test1 = function(){
document.getElementById("demo1").innerHTML += this;
}

//window object calls the function
window.addEventListener("load", test1);

//button object calls the function
document.getElementById("btn1").addEventListener("click", test1);

var test2 = () =>{
document.getElementById("demo2").innerHTML += this;
}

//window object calls the function
window.addEventListener("load", test2);

//button object calls the function
document.getElementById("btn2").addEventListener("click", test2);

</script>
</body>
</html>

  • Comments:

    No comment to show.

    To Contact
    Available Services
    Terms and Conditions