CHAPTERSIX
Be focused and you will archive alot. choose your ON javascript
Explore moreBe focused and you will archive alot. choose your ON javascript
Explore moreLorem ipsum dolor sit amet consectetur adipisicing elit. Hic odit rem dolorum molestiae fugit deserunt exercitationem recusandae, itaque ratione harum sit repellat dolor temporibus deleniti non voluptatem nostrum quas? Cumque veniam, molestias id natus pariatur dolores aut nemo iure facilis expedita, temporibus exercitationem ullam ex officiis reiciendis quaerat enim consequuntur.
here are the basic three ways of accesing html elements in javascript
gets the element by its id name
gets all the css selector of the element
gets the element by its class name
Functions allow you to group code into reusable blocks.
Declaring a Function
function greet() { console.log("Hello, World!"); } greet(); // Calling the
function
Function with Parameters
function add(x, y) { return x + y; } console.log(add(5, 10)); // 15
Arrow Functions (Modern JS)
const multiply = (x, y) => x * y; console.log(multiply(3, 4)); // 12
7. JavaScript Events
JavaScript can handle events like clicks, key presses, and form submissions.
✔ Example: Button Click Event
<button onclick="showMessage()">Click Me</button>
<script>
function
showMessage() {
alert("Button Clicked!");
}
</script>
✔ Example: Changing Text on Click
<p id="text">Click the button to change this text</p>
<button onclick="changeText()">Change</button>
<script>
function changeText() {
document.getElementById("text").innerHTML = "Text Changed!";
}
</script>
<!DOCTYPE html> <html> <head> <title>Title of the Page</title> </head> <body> <h1>Click the button to change this text</h1> <button onclick="changeText()">Change</button> <script> function changeText() { document.getElementById("text").innerHTML = "Text Changed!"; } </script> </body> </html>
Title of the Page
Click the button to change this text
<!DOCTYPE html>
<html>
<head>
<title>Title of thePage</title>
</head>
<body>
<p id="demo"></p>
<script>
var x, y, z; //statement 1
x = 5; //statement 2
y = 6; //statement 3
z = x + y; //statement 4
document.getElementById("demo").innerHTML = "the value of z is " + z + ".";
</script>
</body>
</html>
<!DOCTYPE html> <html> <head> <title>Title of thePage</title> </head> <body> <h2>JavaScript Arrays</h2> <p id="demo"></p> <script> var cars = ["Saab" , "Volvo" , "BMW"]; document.getElementById("demo").innerHTML = cars; </script> </body> </html>
Title of thePage
JavaScript Arrays
vildash network team has had alot of impact on others but here are the vildash network team testimonies and expirience while working with the team
you can now connect and text other users from our database. you just neeed to click bellow to message them
WE HAVE CODE EDITORS FOR LANGUAGES LIKE C, C#, C++, HTML, CSS, javascript, JAVA VISUAL BASIC
We dont just teach you to code we teach you to code and build amazing systems.we are group of expert who wants to promote our field of studies