30秒学会 JavaScript 片段 – Detect user color scheme preference in JavaScript
The recently introduced prefers-color-scheme media query allows us to check if the user prefers a li...
The recently introduced prefers-color-scheme media query allows us to check if the user prefers a li...
Finds all the ancestors of an element up until the element matched by the specified selector. Use No...
encodeURIComponent() The encodeURIComponent() function encodes everything in the given string, excep...
The SHA-256 algorithm is a widely used hash function producing a 256-bit hash value. It is used in m...
A very common need when building websites is the ability to copy text to clipboard with a single but...
Returns true if the user color scheme preference is light, false otherwise. Use window.matchMedia() ...
Returns true if the browser tab of the page is focused, false otherwise. Use the Document.hidden pro...
Encode a set of form elements as a query string. Use the FormData constructor to convert the HTML fo...
Returns an object containing the parameters of the current URL. Use String.prototype.match() with an...
Returns true if the element has the specified class, false otherwise. Use element.classList.contains...