Found 10710 Articles for Web Development

How to sort rows in a table using JavaScript?

Rushi Javiya
Updated on 22-Feb-2023 15:13:02

2K+ Views

We can’t use the built-in sort() method of JavaScript to sort the table rows based on the particular column. So, we need to create a custom algorithm to sort table rows. In this tutorial, we will learn to sort tables and rows using JavaScript. Here, we will look at different examples to sort table rows in ascending and descending order. Syntax Users can follow the syntax below to sort rows in a table using JavaScript. var switchContinue = true; while (switchContinue) { switchContinue = false; var allRows = table.rows; for ... Read More

How to solve JavaScript heap out of memory on prime number?

Rushi Javiya
Updated on 22-Feb-2023 17:58:44

175 Views

As the ‘heap out of memory’ error message suggests, it occurs when any JavaScript code takes more memory than allocated memory, when we run any JavaScript program, the computer allocation particular memory to the JavaScript program. When we run code of JavaScript or any programming language, our computer creates a process and allocates fixed memory. When a program needs more memory size, it raises an error like heap out of memory. For example, if we create an array of size 1020 and try to initialize every array index with some value, the heap goes out of memory and raises ... Read More

How to set default values when destructuring an object in JavaScript?

Rushi Javiya
Updated on 22-Feb-2023 15:04:45

5K+ Views

The array and object destructuring feature was introduced in the ES6 version of JavaScript. The destructuring of the array and object allows us to store its values in a separate variable. After that, we can use that variable to access the value of the particular property of the object. The main thing we need to focus on while destructuring the array object is the default values. For example, we have added the property3 variable in the destructuring object, but if the object doesn’t contain the property3, destructuring sets the undefined value to the property3 variable. Users can follow ... Read More

How to set cursor style to pointer for links without href?

Rushi Javiya
Updated on 22-Feb-2023 15:03:05

2K+ Views

We can use the tag in HTML to add a link to the web page. The default cursor style for the elements is the pointer, but removing the href attribute from the tag changes the cursor style. So, in this tutorial, we will learn to keep the cursor style to pointer for tags without the href attribute. Users can follow the example below to check out the default cursor style for the elements Example In the example below, we have used the tag to create three different links. In the output, we ... Read More

How to set cursor position in content-editable element using JavaScript?

Rushi Javiya
Updated on 22-Feb-2023 15:00:56

9K+ Views

In HTML, content editable div allows users to edit the content of the div element. We need to pass the contenteditable attribute with true Boolean value to the div element to make any div element editable. The content editable div contains the caret cursor by default, and sometimes we may require to set the caret cursor position in the content editable div element to edit the content of the div. However, we can set the caret cursor position anywhere by clicking at a particular place in the content editable div. This tutorial will teach us to use different ... Read More

How to send row data when clicking the button using javascript?

Rushi Javiya
Updated on 22-Feb-2023 14:59:49

8K+ Views

The table contains multiple rows, and every row contains multiple columns. Also, every column contains multiple HTML elements or texts. Here, we will add the submit button on every table row, and based on the button click, we will access the row's data. We will use JavaScript and jQuery to access the row data, and after that, users can send it anywhere, wherever they want, using API, etc. Use JavaScript to access row data In this approach, we will access the first clicked element. We will find its parent element based on the clicked element, giving us a particular ... Read More

How to create regular expression only accept special formula?

Rushi Javiya
Updated on 22-Feb-2023 14:56:47

789 Views

The regular expression is a pattern containing various characters. We can use the regular expression to search whether a string contains a particular pattern. Here, we will learn to create a regular expression to validate the various mathematical formulas. We will use the test() or match() method to check if particular mathematical formula matches with regular expression or not Syntax Users can follow the syntax below to create regular expressions accepting special mathematical formulas. let regex = /^\d+([-+]\d+)*$/g; The above regex accepts only 10 – 13 + 12 + 23, like mathematical formulas. Regular Expression ... Read More

How to create dynamic breadcrumbs using JavaScript?

Rushi Javiya
Updated on 01-Mar-2023 10:51:47

3K+ Views

The breadcrumbs help website users to understand the navigation path, and windows file explorer is the best example that provides the breadcrumbs. When you open a file explorer, you can see the current location in the file explorer at the top bar. Also, if you click on any location, it jumps to that location. There are two main benefits of using dynamic breadcrumbs on the website. The first is that users can know about the navigation path, and another is users can jump on any location directly in the navigation path. Here, we will see different approaches to ... Read More

How to disable browser print options (headers, footers, margins) from the page with CSS?

Dishebh Bhayana
Updated on 22-Feb-2023 11:37:47

3K+ Views

We can control the print preview page’s header, footer, and margin just with the help of CSS, and even achieve the desired layout and orientation of the paged media. We will be using @page directive to achieve our results. While previewing a print page in the browser, we see some extra page information, like page title, page preview date and time, and the page number in the preview, all present in the page’s header and footer. We also see some extra margin applied to the page preview media. Syntax @media print { @page { ... Read More

How to create a printable webpage using CSS media queries?

Dishebh Bhayana
Updated on 22-Feb-2023 11:37:11

452 Views

We can create a printable webpage, and control the styling in the print preview of a page using the CSS media query print property, @media print. @media print is a CSS media query that allows us to add page styling to the print preview page of any webpage. Using this, we can create a printable webpage by specifying the “visibility” of an HTML element to “visible” or “hidden” under the given media query, We can also add any other styling we want to have in the print preview screen to the @media print query. Syntax @media print { ... Read More

Advertisements