-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlearning-while-this-project.txt
80 lines (50 loc) · 2.76 KB
/
learning-while-this-project.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
⭐ Javascript
🟢 window.open()
✍ window ka ek method jiska naam hi "open" (window.open) jisse kisi bhi page pr redirect kiya ja sakta hai like anchor tag. Iske sath hi target bhi specify kiya ja sakta hai jaise anchor tag me karte hai _self,_blank,_parent etc...
👉 Example => window.open("https://github.com/WebWithAman","_blank"); - It Will open the Page of Given Url in new window tab.
🟢 HtmlInputElement.focus()
✍ HtmlInputElement.focus() method ka use input element me focus karne ke liye hota hai iska matlab hai is method se input field me cursor put kiya ja sakta hai...
👉 Example => Html Code :
<input id="inputfield">
Javascript code :
document.getElementById("inputfield").addEventListener("mouseenter", function() {
this.focus();
});
🟢 HtmlInputElement.blur()
✍ HtmlInputElement.blur() method ka use input element me se focus hatane ke liye hota hai iska matlab hai is method se input field me cursor ko hide kiya ja sakta hai...
👉 Example => Html Code :
<input id="inputfield">
Javascript code :
document.getElementById("inputfield").addEventListener("mouseenter", function() {
this.focus();
});
document.getElementById("inputfield").addEventListener("mouseleave", function() {
this.blur();
});
🟢 HtmlInputElement.select()
✍ HtmlInputElement.select() method ka use input element me likhe content ko select karne karne ke liye hota hai iska matlab hai is method se input field likha sara content apne aap select ho jata hai...
👉 Example => Html Code :
<input id="inputfield">
<button id="mybtn"> select </button>
Javascript code :
document.getElementById("mybtn").addEventListener("click", function() {
document.getElementById("inputfiled").select();
});
🟢 Listen and Deal with Multiple Events Using One Event Listner
👉 Example => Html Code :
button id="mybtn"> Submit </button>
Javascript Code :
const btn = document.getElementById("mybtn");
const events = ["click", "mouseout", "mouseover"];
events.forEach(function(event) {
btn.addEventListener(event, function(event) {
if(event.type === "click"){
console.log("click event");
}else if(event.type === "mouseout"){
console.log("mouseout event");
}
else {
console.log("mouseover event");
}
});
});