This commit is contained in:
Ilya Kantor 2019-05-16 13:37:21 +03:00
parent 40a4e181be
commit d9740908bf
4 changed files with 5 additions and 5 deletions

View file

@ -47,8 +47,8 @@ while (i) { // when i becomes 0, the condition becomes falsy, and the loop stops
} }
``` ```
````smart header="Brackets are not required for a single-line body" ````smart header="Curly braces are not required for a single-line body"
If the loop body has a single statement, we can omit the brackets `{…}`: If the loop body has a single statement, we can omit the curly braces `{…}`:
```js run ```js run
let i = 3; let i = 3;

View file

@ -1,4 +1,4 @@
Can use `this` in the handler to reference "itself" here: Can use `this` in the handler to reference "the element itself" here:
```html run height=50 ```html run height=50
<input type="button" onclick="this.hidden=true" value="Click to hide"> <input type="button" onclick="this.hidden=true" value="Click to hide">

View file

@ -36,7 +36,7 @@ To get field-relative `left` coordinate of the click, we can substract the field
let left = event.clientX - fieldCoords.left - field.clientLeft; let left = event.clientX - fieldCoords.left - field.clientLeft;
``` ```
Normally, `ball.style.position.left` means the "left edge of the element" (the ball). So if we assign that `left`, then the ball edge would be under the mouse cursor. Normally, `ball.style.position.left` means the "left edge of the element" (the ball). So if we assign that `left`, then the ball edge, not center, would be under the mouse cursor.
We need to move the ball half-width left and half-height up to make it center. We need to move the ball half-width left and half-height up to make it center.

View file

@ -29,7 +29,7 @@ Like this:
So if we set `onclick` on it, then it will catch clicks to the right of the text. So if we set `onclick` on it, then it will catch clicks to the right of the text.
...but `<span>` has an implicit `display: inline`, so it occupies exactly enough place to fit all the text: As `<span>` has an implicit `display: inline`, it occupies exactly enough place to fit all the text:
```html autorun height=50 ```html autorun height=50
<span style="border: solid red 1px" onclick="alert(1)">Sweeties (click me)!</span> <span style="border: solid red 1px" onclick="alert(1)">Sweeties (click me)!</span>