Home / Tài liệu CNTT / Javascript

Javascript

Highlight current section in navbar | menu item on scroll Codepen

Thường sử dụng cho các theme one-page, hay highlight danh mục, index section của 1 trang. Code 1: Highlight menu item on scroll HTML: [crayon-61700df08aa18819090101/] CSS: [crayon-61700df08aa20833331140/] JS: [crayon-61700df08aa23286288011/] Demo: https://codepen.io/zbymhz/pen/ExjRNwZ Code 2: Detect and Highlight current section in navigation HTML: [crayon-61700df08aa25608133988/] CSS: [crayon-61700df08aa28131507826/] JS: [crayon-61700df08aa2a014715955/] Demo: https://codepen.io/davidicus/pen/mEVdPN Code 3: IntersectionObserver – highlight current section …

Xem thêm

JavaScript random number between 1 and 10, 1 and 100

Math.random() Math.random() returns a random number between 0 (inclusive),  and 1 (exclusive): Example // Returns a random number: Math.random(); Try it Yourself » Math.random() always returns a number lower than 1. JavaScript Random Integers Math.random() used with Math.floor() can be used to return random integers. There is no such thing as JavaScript integers. We are …

Xem thêm