Found 10483 Articles for Web Development

How to throw an error in an async generator function in JavaScript ?

Shubham Vora
Updated on 05-Apr-2023 15:53:00

2K+ Views

The code often throws an error, and handling errors is more important. JavaScript also allows users to throw a custom error using the ‘throw’ keyword. We can catch the errors in the catch block. We can use the try-catch syntax to catch errors thrown by normal functions. Let’s understand it by the example below. Example 1 (Throw Errors in Regular Function) In the example below, we have created the throwError() regular function, which uses the throw keyword to throw an error with the custom error message. We have executed the function inside the try block. If the function throws any ... Read More

How to take HTML form data as text and send them to html2pdf?

Shubham Vora
Updated on 23-Nov-2023 13:08:46

2K+ Views

The html2pdf is a JavaScript package that allows developers to convert the html to canvas, pdf, image, etc. It takes html as a parameter and adds that to the pdf or required document. Furthermore, it also allows users to download the document after adding the html content to that. Here, we will access the form and add it to the pdf using the html2pdf npm package. We will see different examples of adding form data to pdf. Syntax Users can follow the syntax below to take html form data as text and send them to html2pdf. var element = document.getElementById('form'); ... Read More

How to switch the language of the page using JavaScript?

Shubham Vora
Updated on 05-Apr-2023 15:50:29

9K+ Views

Whenever you develop a website or application for a worldwide business, you must also focus on which language your audience can understand. For example, English is an international language, but in some parts of the world, people don’t understand English as they speak German, Spanish etc. However, if you have observed, then some websites provide the option to change the website's language. You just need to click on the button, which changes the whole website's language. Have you ever thought about how it is possible? Here, we will learn to switch the language of the web page using JavaScript. Syntax ... Read More

How to Style Google Custom Search Manually using CSS?

Shubham Vora
Updated on 05-Apr-2023 15:47:14

898 Views

Have you ever tried to build a custom search engine? If yes, you are aware of how much effort it takes. The first thing is that we need to create a search algorithm that should show the best matching results when any user searches. It can take a lot of time. Rather than wasting time on creating our search engine, what if we use the Google custom search engine? Yes, you heard right! Google allows us to integrate the search engine on our website, and Google handles everything when any user searches for something on our website. Integrating the Google ... Read More

How to store JavaScript functions in a queue and execute in that order?

Shubham Vora
Updated on 05-Apr-2023 15:45:32

727 Views

Sometimes, developers may require to store the function in the queue and execute it in the order it is stored in the queue. In JavaScript, we can create a queue using the array. We can use the push() method of the array to enqueue the function in the queue and the shift() method to deque the function from the queue. Below, we will see examples of storing JavaScript functions in the queue and executing them in the queue order. Syntax Users can follow the syntax below to store JavaScript functions in a queue and execute in that order. while (queue.length ... Read More

How to store data to DOM?

Shubham Vora
Updated on 05-Apr-2023 15:42:53

2K+ Views

Storing data in the DOM means storing data in plain text format. For example, we store data in the state variable while using React or any other reactive framework. When the user updates the data in the input field, it stores updated data in the state variable. So, we store data in the state variable before we submit the form. At the time of submitting the form, we use the values of the state variables. In vanilla JavaScript, we can do the same, like storing data in plain text format, and whenever we require to submit the form, we can ... Read More

How to show/hide div element depending multiple values using Bootstrap and jQuery?

Shubham Vora
Updated on 05-Apr-2023 15:40:04

3K+ Views

Sometimes, we may require to show and hide div based on the selected values. For example, you want to show the registration or login forms based on the radio button's selected value. Below, we will learn to show/hide the div elements based on the selected value using JQuery. Show/hide the div Element Depending on the Selected Value From the Select Menu In JQuery, we can get the selected option’s value from the ‘select’ menu. After that, we can access the div element according to the selected option value and show them. Syntax Users can follow the syntax below to show/div ... Read More

How to show some custom menu on text selection?

Shubham Vora
Updated on 05-Apr-2023 15:37:29

843 Views

In some text editors, when you select the text, it shows the menu to edit texts and provides functionalities like justifying text, aligning text, increasing the text size, changing colour, etc. Microsoft word is the best example of it. In Microsoft word, when you select any text, it shows the custom horizontal menu to perform some actions on the text. This tutorial will use JavaScript to create a custom menu on the text selection. Syntax Users can follow the syntax below to show some custom menu on text selection. let coOrdinates = document.querySelector(".content").getBoundingClientRect(); let posX = clientX - Math.round(coOrdinates.left) + ... Read More

How to show pagination in ReactJS?

Shubham Vora
Updated on 05-Apr-2023 16:31:34

618 Views

The pagination allows users to show content on different pages. For example, we have thousands of data and want to show that to users on a single webpage. It will look worse if we show thousands of data on a single page, as users must scroll through all data to reach the last data. So, to solve the issue, pagination comes into the picture. We can show a particular number of data on a single page and create a total number of pages according to the total data available. Gmail is the best example of pagination, it shows 50 emails ... Read More

Should I Learn Python or PHP for the Back End?

Tushar Sharma
Updated on 04-Apr-2023 11:46:25

387 Views

A stable online presence is indispensable for both persons and agencies in the modern-day digital era. Web builders are in high demand in order to do this. To guarantee that the entirety features properly, it is crucial to select the fantastic programming language for the returned end. So, one of the most well-liked programming languages is PHP, which has been around for a while and developed a reputation for its unique characteristics. Another popular language is Python and selecting between them can be a challenge. Here, we will explore the differences between Python and PHP and get you ready to ... Read More

Advertisements