Found 10877 Articles for Web Development

How to find position of HTML elements in JavaScript?

Aman Gupta
Updated on 13-Oct-2023 15:44:53

567 Views

Overview JavaScript provides various methods for the manipulation and to get the information about the HTML elements. From the several methods JavaScript has its own predefined methods which returns the specific coordinates or position of the HTML element. These two methods are offsetLeft and offsetTop, these two methods return the exact position of the HTML elements. JavaScript also provides another function as getBoundingClientRect() this method also provides the same result as the offset method. The getBoundingRect() has four properties as top, left, right and bottom and the offset has only two properties that are left and top. Syntax The ... Read More

How to find height of text in HTML canvas using JavaScript ?

Aman Gupta
Updated on 13-Oct-2023 15:42:53

933 Views

Overview A canvas is a HTML element that provides us to display any type of custom text or graphics on the web page. A canvas makes a graphics editable through which we can make our own custom text or design. A canvas element can be added to the HTML using tag or using JavaScript we can add it through the 'document' object 'createElement' method. As we have to find the height of the text that is written in the HTML canvas, we can use the ''textMetrics" objects measureText() property to calculate height of the text. Syntax The Syntax used ... Read More

How to find class of a clicked element using jQuery?

Aman Gupta
Updated on 13-Oct-2023 15:40:44

641 Views

Overview We can easily find the class of the clicked element, the Jquery provides various methods which return the class name of the element when the element is clicked. The Jquery methods "attr()" and using "this.className" properties helps to find the class of an element. So to learn more about these methods we will be seeing the Examples which will cover both the methods. A class name is an attribute which defines the group or type of the data inside the tag. There can be different tags or elements which can contain the same class names but there in case ... Read More

How to find area of a triangle using JavaScript?

Aman Gupta
Updated on 13-Oct-2023 18:31:02

2K+ Views

Overview The area of the triangle refers to the full area which means the perimeter of the triangle and the inside area. So to calculate the area of a triangle we will be calculating the perimeter of its and then the area but all these was the manual understanding of finding it. So by using JavaScript we will be automating this whole process which means a user only enters the sides of the triangle and to the interface and the area of the triangle will be calculated automatically. Expression (Heroine's Formula) The given below shows the heroine's formula expression − ... Read More

How to find element by text using jQuery?

Aman Gupta
Updated on 13-Oct-2023 15:32:02

526 Views

Overview The Jquery consists of a predefined method which makes it easy for the developer to build this feature. The Jquery provides a selector Syntax by which we can find any text element. So the ":contains" selector is used for finding the text in any element. To learn fully about this ":contains" selector we will be developing this feature through an Example. Syntax The Syntax for finding the text in an element is given below − $(selector:contains()); selector − The selector in the above Syntax is termed as any element or class or id name which is ... Read More

How to find average color of an image using JavaScript?

Aman Gupta
Updated on 13-Oct-2023 15:30:31

364 Views

Overview The extraction of colors from an image means that the colors which are present in an image in the form of pixels will be extracted, and an average of the pixels of the distinct is calculated in the form of RGB (Red Green Blue) and a new average color will be formed on the basis of the average of the color pixels. So we can achieve this with the help of JavaScript, in the JavaScript there is a property "canvas" which is used to draw an image or any content in the form of pixels. Approach To build this ... Read More

How to find textareas and makes a border using jQuery?

Aman Gupta
Updated on 13-Oct-2023 14:32:13

62 Views

Overview For finding any element Jquery provides the best Syntax for the selector, it gives us a one line code for selecting any element from the HTML document. So to find all the textareas in the HTML we will be using the Jquery selector which will select the textareas and then by using the Jquery CSS(Cascading Styles Sheet) manipulation we will be making a border around the textarea. The border makes a User Interface more attractive. Syntax The Syntax for selecting and styling any element in Jquery is given below $(selector).css(); $(selector) − . For selecting any ... Read More

How to find all selected options of HTML select tag?

Aman Gupta
Updated on 13-Oct-2023 15:27:48

137 Views

Overview To get the selected options from a dropbox we will be using the JavaScript library that is Jquery. The Jquery provides the feature to select and find the options in the optimum lines of code. For this we will be using pseudo selector class ":selected" for the single selection and multiple selection. So for this in the single selection we will directly alert the user and in multiple we will be storing the Output in the array then displaying it on the screen. Syntax The Syntax used in this feature is − $("option:selected").text(); option:selected − The ... Read More

How to find all inputs with a value Green and change the text of next sibling span using jQuery?

Aman Gupta
Updated on 13-Oct-2023 15:25:45

64 Views

Overview Using Jquery we can create this feature, as Jquery library provides the methods for changing the span text to the value of the input value. In this feature we should have a prior knowledge of the basic HTML and the Jquery. So the Jquery provides the methods as next() and text(), these two methods play a vital role in building this feature. We will also use a few styling methods to make the change visible from other normal text. Syntax The Syntax used in this feature is − $(selector).next().text("text"); selector − The selector in the above ... Read More

How to find all the elements that are disabled in jQuery?

Aman Gupta
Updated on 13-Oct-2023 15:24:24

432 Views

Overview The disabled elements are the elements which are not usable for the end user. These elements are disabled using the "disable" attribute. So using the JQuery library we can find all the total number of disabled elements in a HTML page. Using the Jquery selector we can find all the disabled elements by passing the ":disabled" pseudo selector. The ":disabled" selector will select all the elements in the top−down approach. This approach will scan all the disabled attributes and will list it out in a variable. Syntax The Syntax used in this approach is − $(":disabled").each(function () { ... Read More

Advertisements