JavaScript Tutorial
JavaScript Tutorial
If ,else, else if
Instead of above statements we use ternary.
Instead of if, if else, we use switch for code readability.
What is dom ?
Document.getElementByid(mbh).innerHtml=”Mounika”;
After execution by inspecting the id value can change so we use class
names to get value
But if many lines have same classes it get conflict for that we use id in
jquery by
1. ^id if id first and later any data eg:id7dfhd4
2. $id if id is last and front some other data E g:hdh634id
3. *id if any place d matches Eg :&GGJJ86id^&NH
Eg :vegetables peel cutting(variables, strings, properties etc ) last
cooking(cooking is Dom)
Splicing an Array
Example
<!DOCTYPE html>
<html>
<body>
<h2>splice()</h2>
<p id="demo1"></p>
<p id="demo2"></p>
<p id="demo3"></p>
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo1").innerHTML = "Original
Array:<br> " + fruits;
function myFunction() {
var removed = fruits.splice(2, 2, "Lemon", "Kiwi");
document.getElementById("demo2").innerHTML = "New
Array:<br>" + fruits;
document.getElementById("demo3").innerHTML = "Removed
Items:<br> " + removed;
}
</script>
</body>
</html>
The slice() method slices out a piece of an array into a new array.
<html>
<body>
<p>This example slices out a part of an array starting from array element
1 ("Orange"):</p>
<p id="demo"></p>
<script>
var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
var citrus = fruits.slice(1);
document.getElementById("demo").innerHTML = fruits + "<br><br>" +
citrus;
</script>
</body>
</html>
slice()
This example slices out a part of an array starting from array element 1
("Orange"):
Banana,Orange,Lemon,Apple,Mango
Orange,Lemon,Apple,Mango
Create an HTML element document.createElement(element)
addEventListener():
Instead of writing onchane in the input tag we will write event listerners.
Domain Name:
technology examples :
Tablets.
Laptops.
Communication Technology Labs.
Interactive Whiteboards.
Robotics.
3-D Printers.
Digital Cameras.
Video Cameras.
Variables declared with var and let are quite similar when declared inside a
function.
addEventListener()
The addEventListener() method allows you to add many events to the same
element, without overwriting existing events: