In jQuery, you can use the $.each() method to loop through a collection of elements or objects. In vanilla JavaScript, you can achieve the same functionality using the forEach() method, which is...


Vanilla JavaScript equivalent of jQuery parent
14 May, 2023
To use these, you first need to get a reference to the child element whose parent you want to get. You can use a method such as getElementById(), querySelector(), or getElementsByClassName() to get a...

Vanilla JavaScript equivalent of jQuery hasClass
14 May, 2023
Both the native JavaScript and jQuery methods achieve the same result of checking whether an element has a particular class. However, the syntax and implementation are different between the two. In...

Get current focused element in JavaScript
14 May, 2023
When developing a webpage or web application, it can be useful to know which element is currently in focus. This information can be used to provide visual feedback or to perform actions based on the...

"do-while" loop in PHP
30 Apr, 2023
A "do-while" loop is a type of loop construct used in programming to execute a block of code repeatedly until a certain condition is met. The code inside the "do" block will be executed at least once...

Run Part of Your MQL5 Code Every Minute
30 Apr, 2023
If you prefer not to run your code on every tick, you can schedule it to run during the launch of a new bar or after any specific time period. This can be a useful feature for those who want more...

Clearing Cache in Drupal 10
28 Apr, 2023
The snippet shows how to clear Drupal 10 cache programmatically. You can do that for all of the cache or one by one using the ID of the cache that you want to clear.

Get Full/Absolute URL in Drupal 10
27 Apr, 2023
Get the full/absolute URL of a page in Drupal 10 using the Url class. This snippet covers how to get the URL of the current page, a specific route, or an external website, and how to convert the URL...

Load a File by URI in Drupal 10
27 Apr, 2023
Load a file entity in Drupal 10 by using its Uniform Resource Identifier (URI). This snippet provides a simple code example that demonstrates how to load a file entity by URI and check if it was...

Creating a Patch File from a Git Commit
27 Apr, 2023
A patch file contains the differences between two sets of code, and can be used to apply changes to another codebase. In Git, you can create a patch file from a specific commit by using the "git...