Skip to content

Browser default actions #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip task translation
  • Loading branch information
msisaifu committed Mar 16, 2021
commit 057b9551c15cbcdb0179591cc7edf93cca3a59d1
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<div id="text">Text</div>

<script>
// Here it doesn't matter how we hide the text,
// could also use style.display:
// অনেকভাবেই আমরা এটিকে অদৃশ্য করতে পারি,
// style.display ও কাজ করবে:
document.getElementById('hider').onclick = function() {
document.getElementById('text').hidden = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ importance: 5

---

# Hide on click
# ক্লিকের মাধ্যমে অদৃশ্য

Add JavaScript to the `button` to make `<div id="text">` disappear when we click it.
একটি বাটনে `button` ক্লিক হলে এটি `<div id="text">` কে অদৃশ্য করবে।

The demo:
ডেমো দেখুন:

[iframe border=1 src="solution" height=80]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Can use `this` in the handler to reference "the element itself" here:
হ্যান্ডেলারে `this` ব্যবহারের মাধ্যমে করতে পারি "কেননা `this` দ্বারা ঐ এলিমেন্টকে নির্দেশ করে":

```html run height=50
<input type="button" onclick="this.hidden=true" value="Click to hide">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ importance: 5

# Hide self

Create a button that hides itself on click.
একটি বাটন লিখুন যেটি ক্লিক করলে বাটনটিই অদৃশ্য হয়ে যাবে।

```online
Like this:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
The answer: `1` and `2`.
উত্তর হল: `1` এবং `2`

The first handler triggers, because it's not removed by `removeEventListener`. To remove the handler we need to pass exactly the function that was assigned. And in the code a new function is passed, that looks the same, but is still another function.
প্রথম হ্যান্ডেলারটি রান হবে, কেননা এখানে `removeEventListener` এর মাধ্যমে হ্যান্ডেলারটি রিমুভ হবে না। কোন হ্যান্ডেলার রিমুভ করতে আমাদের সেম ভ্যারিয়েবল ফাংশন অথবা ফাংশন পাঠাতে হবে। কিন্তু এখানে একই লজিকের দুটি ফাংশন পাঠানো হচ্ছে, একই রেফারেন্সের না।

To remove a function object, we need to store a reference to it, like this:
কোন হ্যান্ডেলার রিমুভ করতে আমাদের এভাবে লিখা লাগবে:

```js
function handler() {
Expand All @@ -13,4 +13,4 @@ button.addEventListener("click", handler);
button.removeEventListener("click", handler);
```

The handler `button.onclick` works independently and in addition to `addEventListener`.
আবার `addEventListener` এর পাশাপাশি `button.onclick` ও কাজ করবে।
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ importance: 5

---

# Which handlers run?
# কোন হ্যান্ডেলারটি এক্সিকিউট হবে?

There's a button in the variable. There are no handlers on it.

Which handlers run on click after the following code? Which alerts show up?
বাটন ক্লিকে এখানে কোন হ্যান্ডেলারটি রান হবে, এবং কোন অ্যালার্টটি শো হবে?

```js no-beautify
button.addEventListener("click", () => alert("1"));
Expand Down