Found 10710 Articles for Web Development

How to add default horizontal scaling to a canvas-type text with JavaScript?

AmitDiwan
Updated on 06-Feb-2023 12:30:31

222 Views

We can add default horizontal scaling to a canvas-type text by accessing the canvas context and setting the scale property to a specific value. This can be done by calling the context's scale method and passing in the desired value for the horizontal scaling. By doing this, all text drawn on the canvas will have the default horizontal scaling applied to it. HTML Canvas HTML canvas is a 2D drawing surface that can be used to create dynamic and interactive graphics, charts, and animations on web pages. It is an HTML element that allows developers to draw graphics using JavaScript. ... Read More

How to add content in section using jQuery/JavaScript?

AmitDiwan
Updated on 06-Feb-2023 12:23:53

1K+ Views

We can use jQuery's 'append' or 'prepend' method to add content to the section of a website. This can be done by selecting the element using jQuery's 'selector' method and then using the appropriate method to add the desired content. Additionally, we can also use JavaScript's 'innerHTML' property to add content to the section. There are quite some ways of adding content to head tag programmatically. Today we are going to discuss 3 of them − Using jQuery's .append() method − Using JavaScript's document.createElement() method − Using JavaScript's insertAdjacentHTML() method − Using these 3 ways ... Read More

How to Add Commas Between a List of Items Dynamically in JavaScript?

AmitDiwan
Updated on 06-Feb-2023 12:21:39

2K+ Views

We can use the CSS "::before" pseudo-element to dynamically add a comma before each list item, except for the first one. By targeting the list item and using the "content" property, we can insert a comma before the list item's content. Additionally, we can use the ":not(:first-child)" pseudo-class to ensure that only the non-first list items have the comma added. Consider we have the following HTML DOM: Item 1 Item 2 Item 3 Item 4 We will discuss two different approaches in this article that ... Read More

How to add class to an element without addClass() method in jQuery?

AmitDiwan
Updated on 10-Apr-2023 14:49:19

6K+ Views

We can use the .attr() method to add a class to an element. This method can be used to set or get the value of an attribute on an HTML element. To add a class, we first select the element using a jQuery selector, and then call the .attr() method, passing in "class" as the first argument and the class name as the second argument. Let us first understand what jQuery is. jQuery is a JavaScript library that simplifies HTML document traversing, event handling, and animation. It allows for easy manipulation of the Document Object Model (DOM). It also provides ... Read More

How to Add and Remove multiple classes in jQuery?

AmitDiwan
Updated on 06-Feb-2023 11:54:44

9K+ Views

We can use the jQuery .addClass() method to add multiple classes to an element. We simply need to pass a string of class names separated by a space as the argument. To remove multiple classes, we use the .removeClass() method and pass in the same string of class names. Both of these methods can be chained together to add and remove multiple classes at once. But before proceeding with that let us have a look at what jQuery offers and how it makes web programming easier over plain JavaScript. What is jQuery jQuery is a JavaScript library that simplifies ... Read More

How to add an element horizontally in HTML page using JavaScript?

AmitDiwan
Updated on 06-Feb-2023 11:51:23

2K+ Views

We can use the JavaScript method "createElement" to create a new element. Then, we can use the method "appendChild" to add the element to a parent element on the HTML page. To position the element horizontally, we can use CSS styles such as "display:inline-block" or "float:left/right" on the newly created element. Suppose a situation where we want to depict a graphical representation of a Linked List data structure. Every time the user clicks on a button, a new node, represented by a green circle in our case, should get prepended to the list of nodes horizontally. And the text inside ... Read More

How to add an active class on click event in a custom list group in Bootstrap?

AmitDiwan
Updated on 06-Feb-2023 11:48:16

6K+ Views

We can add an active class to a custom list group item in Bootstrap 4 by using JavaScript or jQuery. This can be achieved by adding an onclick event to each list group item and then using the "addClass" method to add the active class to the item that was clicked. By doing this, we can easily create a custom list group with an active state that changes based on user interaction. Bootstrap Intro Bootstrap is a popular open-source front-end development framework. It helps to create responsive and mobile-first webpages by providing a set of pre-designed CSS and JavaScript ... Read More

How to add a tooltip to a div using JavaScript?

AmitDiwan
Updated on 06-Feb-2023 11:44:48

12K+ Views

To add a tooltip to a div using JavaScript, first create a function that will generate the tooltip content. Next, add an event listener to the div that will call the function and display the tooltip when the div is hovered over. Finally, use CSS to style the tooltip and position it appropriately. A tooltip is a small text box that appears when a user hovers over a specific element on a webpage, such as a button, link, or image. The tooltip typically contains additional information or context about the element that the user is hovering over. Tooltips are commonly ... Read More

How to implement multiple input checkbox in vanilla JavaScript?

AmitDiwan
Updated on 06-Feb-2023 11:34:17

632 Views

We will learn how to implement multiple input checkbox. The checkbox input selector will have the following functionalities − Multiple options can be selected using the checkbox. Chosen options will be displayed as a separate list. Delete icon will be provided against each chosen option to uncheck / delete that option. Another thing to note is that we will not be using any third-party library to achieve these functionalities and everything will be written in HTML + JavaScript + CSS only. Approach We will have an object whose key will be used as the label for checkbox ... Read More

How to Access element from Table using JavaScript?

AmitDiwan
Updated on 06-Feb-2023 11:20:03

10K+ Views

To access a element from a table using JavaScript, you can first use the document.getElementById() or document.getElementsByTagName() method to access the table element. Then, you can use the table's childNodes property to access the elements within the table. Our focus will be on changing the background color of the current row (the row on which we currently are) when we hover over it and reverting the background color to normal when the mouse goes away.Example Therefore, let’s suppose we have the following HTML code to render a table. ... Read More

Advertisements