Practical solutions

JavaScript Howtos How-To Guides

Solve the problem. Keep building. Collection of JavaScript how-to articles

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Validate Zip Code Validation in JavaScriptIn this article we are going to learn how to use regular expression for validation of zip code using JavaScript code with different examples. How to Scroll to Bottom of a Div in JavaScriptThis article will teach you how to scroll to bottom of a div using a combination of scrollTop and scrollHeight, jQuery, jQuery .animate(), Element.scroll(), and Element.scrollIntoView(). How to Replace Space With Underscore in JavaScriptIn this article we are going to learn how to replace all spaces from given string values using multiple methods in JavaScript code with different examples. How to Jump to Anchor in JavaScriptThis article teaches how to focus and redirect to specific content of webpage from given anchor URL using JavaScript code with different examples. How to Strip HTML Tags From String in JavaScriptThis article introduces how to strip HTML tags from strings using a regular expression, the textContent method, jQuery, the DOM parser interface, and strip-string-html package. How to Extract the First Child of an Element in JavaScriptIn today's post, we'll learn to extract the first child of an element in JavaScript. How to Create Customized Alert Box in JavaScriptThis article teaches you how to create a customized alert box using jQuery UI, SweetAlert2, and a custom alert function. How to Convert XML to JSON in JavaScriptIn this article, learn how to convert XML strings to JSON format data with the help of regex and default string method matchAll() in JavaScript. How to Get the Selected or Highlighted Text in JavaScriptIn this article, we will see how to get the text that is selected by the user on the screen in JavaScript. How to Add Vector Class in JavaScriptThis article will teach you how to add vectors in JavaScript using a for loop, ES6 Map, ES6 class, and extending the native Array class. How to Validate Email With Regex in JavaScriptThis article will teach you multiple regular expressions that'll validate an email address in JavaScript. So you can select a pattern that suits your use case. How to Use __dopostback() in JavaScriptThe __dopostback() function is that extra feature that makes the web task more efficient. Technically, when a form or data is to be stored via a post method, it does not reload the webpage with a new instance. But, in real case scenario, the __dopostback() function ensures the post is done correctly. How to Sanitize String in JavaScriptThis JavaScript tutorial article explains what it means to sanitize data in JavaScript. Moreover, it discusses the different packages you can use to sanitize strings in JavaScript. How to Round Number to the Nearest 10 in JavaScriptJavaScript has native methods for rounding numbers. In this JavaScript article, you will learn how to use the Math.ceil() and Math.round() functions to round a number up or to the nearest 10. How to Match Multiple Occurrences With Regex in JavaScriptThis tutorial discusses what a regular expression is and the different methods to match multiple occurrences in JavaScript. How to Mask Input Text Without a Plugin Using JavaScriptThe JavaScript Input Mask or masked textbox is a control that provides an easy and reliable way for the user to collect input based on a standard mask. In this article, we will explore input text masking without a plugin using JavaScript. How to Marquee Element in JavaScriptIn this article we'll learn how to use marquee on webpage content using HTML tag and JavaScript custom function with different examples. How to Implement DOM Data Binding in JavaScriptThis JavaScript instructional post will tell you what is data binding and what are different methods to bind data in JavaScript. How to Get the Domain Name in JavaScriptIn this article, we are going to learn how to get domain name programmatically during the execution of a webpage using JavaScript events and functions. How to Fix Maximum Call Stack Size Exceeded Error in JavaScriptThere are numerous steps that you can take to fix a code that's eating up all of the available call stack within a browser. Through this JavaScript article, we'll go over in great detail what causes a Maximum Call Stack Size Exceeded error and how we can fix it. How to Destroy Object in JavaScriptDeletion of an object or its property can be performed by the delete operator and by creating a constructor that will hold a destroy method. The basic necessity for this drive is to keep track of elements and alter them according to need. JavaScript still does not have in-built ways of directly vanishing an object. How to Clear Canvas in JavaScriptThis short article demonstrates how to clear canvas in JavaScript. How to Call External JavaScript Functions From Java CodeIn this article, we will learn how to include a JavaScript source in a Java program and call a JavaScript function from a Java code. How to Add JavaScript MDCRipple to Ajax Loaded ButtonThis article teaches you how to add MDCRipple to an HTML button loaded via AJAX. We'll set up a local server. Afterward, we'll import the MDC CSS and JavaScript files via UNPKG CDN.