How to set placeholder value for input type date in HTML 5 ?
To set a placeholder value for the input type date in HTML5, use the placeholder attribute. The placeholder attribute doesn’t work well with input type “date.” Use onfocus="(this.type='date')" for a custom placeholder, enabling a date selection dropdown....
read more
How to create dictionary and add key–value pairs dynamically?
This article will teach you how to make a dictionary in JavaScript by using objects to store key-value pairs. Although JavaScript doesn’t have a built-in “dictionary” type, we can effectively create one using JavaScript Objects. Let’s start by creating a new JavaScript Object to act as our dictionary....
read more
What is export default in JavaScript ?
The export statement is used when creating JavaScript modules to export objects, functions, and variables from the module so they can be used by other programs with the help of the import statements. There are two types of exports. One is Named Exports and the other is Default Exports....
read more
Difference between JSON and XML
JSON (JavaScript Object Notation) is a lightweight data-interchange format and it completely language independent. It is based on the JavaScript programming language and easy to understand and generate....
read more
How To Add Google Translate Button On Your Webpage?
Google Translate is a free multilingual machine translation service developed by Google, to translate text from one language into another. It offers a website interface, mobile apps for Android and iOS, and an API that helps developers build browser extensions and software applications. Google Translate supports over 100 languages at various levels. Follow the steps to add a google translate button on your website: Step 1: Start with a basic web page and add a “div” element. In the code below a “div” element with the id “google_translate_element” is created.  Step 2: Add google translate api reference.  Step 3: Add Javascript function..  Example:...
read more
How to display error without alert box using JavaScript ?
Errors in JavaScript can be displayed without the use of alert boxes but using the alert box is the traditional way to do that. We can show errors with different methods without using the alert box....
read more
How to make JavaScript wait for a API request to return?
Prerequisite:Async/Await Function in Javascript...
read more
How to scroll to an element inside a div using javascript?
To scroll to an element inside a div using JavaScript, you can use the `scrollTop` property of the parent div, setting it to the target element’s `offsetTop`. This adjustment allows you to smoothly navigate to a specific element within a scrollable container without using a full-page scroll. There are lots of methods to scroll to an element. The following are the methods available in JavaScript to scroll to an element....
read more
How to convert blob to base64 encoding using JavaScript ?
Blob is a fundamental data type in JavaScript. Blob stands for Binary Large Object and it is a representation of bytes of data. Web browsers support the Blob data type for holding data. Blob is the underlying data structure for the File object and the FileReader API. Blob has a specific size and file type just like ordinary files and it can be stored and retrieved from the system memory. Blob can also be converted and read as Buffers. Buffers are very handy to store binary data such as the binary data of an image or a file. We will be using the FileReader API to convert Blob to a Base64 Encoded String in JavaScript....
read more
How to take screenshot of a div using JavaScript ?
A screenshot of any element in JavaScript can be taken using the html2canvas library. This library can be downloaded from its official website. The below steps show the method to take a screenshot of a <div> element using JavaScript....
read more
How to Align modal content box to center of any screen?
...
read more
How to clear cache memory using JavaScript?
Unlike mobile applications, a web browser doesn’t allow to clear its cache memory. Though we cannot clear all cache of the client browser it is still possible to load the webpage without caching by using meta tags in the HTML code....
read more