Found 10710 Articles for Web Development

Retrieve the position (X,Y) of an HTML element

AmitDiwan
Updated on 01-Nov-2022 11:57:44

4K+ Views

The X, Y position of an HTML document represents X as horizontal whereas Y vertical position. Here, we will see two examples to get the position i.e. Get the position of a specific text on a web page. Get the position of buttons on a web page. Get the position of a specific text on a web page To get the position of a specific text on a web page, we will use the getBoundingClientRect() method. It provides information about the size of an element and its position relative to the viewport. This will give us the ... Read More

How can I make a div not larger than its contents?

AmitDiwan
Updated on 01-Nov-2022 11:51:18

78 Views

To make a div not larger than its contents, use the display property with the value inline-block. We have a div here with an image − The div is styled with inline-block. This inline-block would form a div not larger than its contents − .wrapper{ display: inline-block; border: 10px solid orange; } The image is given a border − img{ border: 20px solid white; } Example Let us now see the complete example − DOCTYPE html> ... Read More

Can you nest HTML forms?

AmitDiwan
Updated on 01-Nov-2022 11:28:05

2K+ Views

In HTML, we cannot nest HTML forms, but we can add multiple forms. Let us see an example of multiple forms, wherein we will add more than one form, upload buttons and multiple Submit buttons. First, we will set the 1st form. This allows uploading only a single file − Select a file: Just after that, we have used and then comes the 2nd form. This allows uploading multiple files − Select a file: ... Read More

How to set a value to a file input in HTML?

AmitDiwan
Updated on 01-Nov-2022 11:23:19

4K+ Views

To set a value to a file input in HTML, use the type attribute. It defines a Browse button to upload the files with a file-select field − However, we cannot set a specific value to a file input in HTML for security reasons. Nothing will happen, even if, let’s say we set a value like this − Let us see some examples to upload single and multiple files with input type file. File select with only one file Example This allows a user to upload only a single file − DOCTYPE html> ... Read More

How do I create an HTML button that acts like a link?

AmitDiwan
Updated on 25-Oct-2022 07:39:10

3K+ Views

We can easily create an HTML button to act like a link and clickable. Let us see the following examples − Create an HTML button link with the tag Create an HTML button link with the tag Create an HTML button link with the onclick event Create an HTML button link with the tag In this example, we will create a link button with tag. The tag is set inside the tag for this − Tutorial Library ... Read More

How to prevent buttons from submitting forms in HTML?

AmitDiwan
Updated on 25-Oct-2022 07:02:55

3K+ Views

To prevent forms from being submitted, we can use the onsubmit property. We can also use the event.preventDefault() method − Prevent buttons from submitting forms using the onsubmit property Prevent buttons from submitting forms using event.preventDefault() Prevent buttons from submitting forms using the onsubmit property We can prevent form from submitting using the onsubmit property as shown below − We have returned false above in the tag itself to prevent form from submitting. Example Let us see the complete example − doctype html> Details ... Read More

How to get the length of a string in bytes in JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:35:40

3K+ Views

In this tutorial, we are going to learn how can we get the length of a string in bytes in JavaScript. Before going into this we should what a byte is. A byte is a unit of data that is 8 binary bits long i.e., 1 byte can hold up to 8 bits of binary data. A byte is a unit most computers use to represent a character such as a letter, number, or typographic symbol. Some examples of strings and their length in bytes are given − Input "Tutorials Point" Output 15 bytes Input 20€ Output 5 bytes Input ... Read More

How to find all elements in a given array except for the first one using JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:29:34

1K+ Views

In this tutorial, we are going to find all the elements present in the given array except the first element using JavaScript. Here we will create one array and using JavaScript will print all the elements on the HTML page leaving the first element. There are mainly two approaches we can use to do the above task. Both the methods are given as − Approach 1: By using the slice() Method The slice() method is a JavaScript method that is used to slice out the required amount of elements from the array. Syntax The following syntax can be used with ... Read More

How to find every element that exists in any of two given arrays once using JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:25:46

175 Views

In this tutorial, we are going to learn how can we find every element that exists in any of the two given arrays once means we need to take two arrays filled with some elements and then from those two arrays create a new array which contains all the elements present in both the array once i.e., no element should be repeated in the new array created. For example, we take two arrays and find every element that exists in any of the two arrays once Input const arr1 = [1, 2, 3, 4, 5] const arr2 = [1, 4, ... Read More

How to find the binomial coefficient of two integers using JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:22:21

325 Views

In this tutorial, we are going to learn how to find the binomial coefficient of two integers using JavaScript. Before learning it we should know what binomial coefficient is and what it refers to. What are Binomial Coefficients? Binomial coefficients refer to the positive integers that occur as coefficients in the binomial theorem. A binomial coefficient C(n, k) can be defined as the coefficient of x^k in the expansion of (1 + x)^n. A binomial coefficient of two numbers n and k signifies the number of combinations of r items that can be selected from a set of n items. ... Read More

Advertisements