Learn JavaScript by Example: Tutorials, Code Snippets & How-To’s

JavaScript Logo

Learn JavaScript in simple and easy steps starting from basic to advanced concepts, with examples including JavaScript tutorials, code snippets, use cases and scenarios.

Vanilla JavaScript or plain JavaScript does not require any third-party libraries or frameworks, and it offers, natively, prototype-based objects, AJAX animations, events, regular expressions, functions as first-class objects, closures, maths libraries, array libraries, string libraries, promises and more.

Also check our JavaScript blog for more resources and tutorials.

Do you need to enable JavaScript in your browser?

Implementing Custom Tooltips with Vanilla JavaScript

The following script replaces the native browser tooltip with a custom-styled tooltip that appears when hovering over elements with the class hasTooltip.​ See the Pen JavaScript Title Tooltip by Ciprian (@ciprian) on…

Enhancing <select> Dropdowns: Removing Duplicates and Sorting Options with Vanilla JavaScript

When working with <select> dropdowns in HTML, it’s common to encounter scenarios where you need to remove duplicate options or sort them alphabetically. Removing Duplicate <option> Elements Duplicate options in a dropdown…

Creating an Autocomplete Search Feature Using Vanilla JavaScript

Autocomplete search is a powerful feature often used in search fields to provide real-time suggestions as users type. We’ll build a simple input field that sends user input via an AJAX request…

Sorting and Ordering Elements Based on Data Attributes with Vanilla JavaScript

Sorting elements on a webpage can be a critical feature when you need to reorder content dynamically. Whether it’s based on custom order parameters or alphabetically, you can achieve this with vanilla…

Sort Elements Based on Data Attributes with Vanilla JavaScript

In a recent project, I was tasked with sorting a large list of elements dynamically based on multiple data attributes. Below, I’ll show you how to achieve this using just data attributes…

Trigger an Event When User Reaches the Bottom of the Page

In a previous project, a client requested an action to be performed when the user scrolled to the bottom of the page or reached the last element in a list. Here’s how…

Generate a Password Using Vanilla JavaScript

Enforcing strong passwords can be challenging, but by providing users with an automated password generation feature, you can enhance both security and user experience. HTML Structure Note: The input type is set…

Equal Height for All Elements Using Vanilla JavaScript

In my ImagePress plugin, we needed to ensure that all boxes have the same height after they have been loaded. Given the following DOM structure: I used the following function: This function…

Ping a Remote PHP File and Store Data in a MySQL Database with JavaScript

Recently, I needed to store details in a remote database using JavaScript. The straightforward approach was to send a GET request to a PHP file on the server. PHP Script The PHP…

How to Measure Page Loading Time with JavaScript

This approach demonstrates how to measure the loading time from the moment a user clicks on a link until the destination page fully loads. It’s particularly useful for tracking the performance of…

All JavaScript Topics

Vanilla JavaScript Repository ⟶

A Repository of Fine JavaScript Libraries and Components

Best free JavaScript & CSS libraries for modern web design.
All scripts and libraries have been created in-house, either as client work or simply as a demo. Feel free to use and improve upon any of them.