Found 6685 Articles for Javascript

Why do we have External CSS and JS files

Devesh Chauhan
Updated on 27-Feb-2023 14:38:26

329 Views

In this article we will learn about the CSS and JS files. We will explore about their functions and different ways of using them in HTML document. And after learning about all these things we will understand why we have external CSS and JS files.CSS CSS stands for Cascading Style Sheets. CSS is used to apply styles to your websites and webpages. It is used to make webpages look more understandable, presentable and more appealing to the user. A CSS file can be written in any text editor but must be saved with a .css extension. A simple HTML ... Read More

How to simulate target="_blank" in JavaScript ?

Gungi Mahesh
Updated on 24-Feb-2023 13:33:10

5K+ Views

The onclick event occurs only when a user clicks the elements and it is a purely JavaScript attribute. Whenever you click on the onclick event it does some actions like displaying a message or redirects the user another page. The onclick event must be used very less in the website, because it may create the confuse to the users. So, use these event very wisely. The window.open() method is used to open the links or web pages in a new window or tab in the browser. It is supported by all the famous browsers like chrome, firefox, and opera. window.open() ... Read More

How to simulate a click with JavaScript ?

Gungi Mahesh
Updated on 24-Feb-2023 13:30:57

1K+ Views

The getElementById() produces an object of element which represents the element whose id attribute matches the provided string. Because element IDs must be unique if supplied, they're a convenient method to rapidly retrieve a single element. Whenever you click on the onclick event it does some actions like displaying a message or redirects the user another page. The onclick event must be used very less in the website, because it may create the confuse to the users. So, use these event very wisely. The ‘textContent’ property of the element, is used to set or return the content of the text. ... Read More

How to set textarea scroll bar to bottom as a default using JavaScript/jQuery?

Gungi Mahesh
Updated on 24-Feb-2023 13:25:28

2K+ Views

The scrollTop property of HTML DOM elements is used to set or return the number of pixels of an elements content which is scrolled vertically. Suppose if the scroll bar is not generated by the content elements then the value of the scrollTop is zero. The onclick event occurs only when a user clicks the elements and it is a purely JavaScript attribute. Whenever you click on the onclick event it does some actions like displaying a message or redirects the user another page. The onclick event must be used very less in the website, because it may create the ... Read More

How to set stroke width of a canvas circle using Fabric.js ?

Gungi Mahesh
Updated on 24-Feb-2023 13:23:00

325 Views

The stroke and strokeWidth property is used to set the stroke color and strokeWidth of a canvas circle. The Circle Class contains the different properties, but to set the stroke color and width we use the stroke and strokeWidth property. The strokeWidth property is used to specify the width for the circle of canvas. The Fabric.js Circle class is used to provide the circle shape by using the fabric.Circle object. The Circle object is used to provide the circle shape, and the circle is movable, and it can be stretched according to the requirements. For the stroke, color, width, height, ... Read More

How to set location and location.href using JavaScript?

Gungi Mahesh
Updated on 24-Feb-2023 13:15:27

3K+ Views

As we know, the onclick event occurs only when a user clicks the elements and it is a purely JavaScript attribute. Whenever you click on the onclick event it does some actions like displaying a message or redirecting the user to another page. The onclick event must be used very less in the website, because it may create the confusing to the users. So, use these event very wisely. The window.location object is used to get the current page URL and it redirects the browser completely to a new page. It can be written without the prefix i.e., window-like location.href, ... Read More

How to set full-screen iframe with height 100% in JavaScript?

Gungi Mahesh
Updated on 24-Feb-2023 13:13:05

3K+ Views

The style.height property is used to set the full-screen iframe with 100% height, and it returns the string value, which represents the height of an element. Auto is the default value of these height property. Here we use the onclick event to make changes effective after clicking the button. The onclick event occurs only when a user clicks the elements and it is a purely JavaScript attribute. Whenever you click on the onclick event it does some actions like displaying a message or redirects the user another page. The onclick event must be used very less in the website, because ... Read More

How to create an array with random values with the help of JavaScript?

Tarun Singh
Updated on 23-Feb-2023 14:02:59

6K+ Views

We can use JavaScript Math.random() method to generate random values. JavaScript provides us with different Array methods, such as from(), fill(), and push(), that can be used to create an array with random values. Arrays in JavaScript are a powerful feature that allows you to store a collection of values of different data types. They are widely used in many applications, and having an array with random values can be very useful in certain scenarios. An array of random values is a collection of randomly generated numbers stored in an array. The values in an array of random values can ... Read More

How to Create an Array using Intersection of two Arrays in JavaScript?

Tarun Singh
Updated on 23-Feb-2023 14:01:10

2K+ Views

The intersection of two arrays in JavaScript can be done in different ways, such as using the Set, spread operator, filter() method, or the includes() method. Each method has its own advantages and disadvantages, and it is important to consider which method works best for the given task. The intersection of two arrays is helpful if you want to create a new array that contains only the elements found in both arrays. Let’s have an example − arr1 = [ 2, 5, 7, 9, 11, 13, 15, 17 ] arr2 = [ 1, 3, 5, 7, 11, 13, 16, 17 ... Read More

How to create an array of partial objects from another array in JavaScript?

Tarun Singh
Updated on 23-Feb-2023 13:58:54

10K+ Views

Arrays are one of the most commonly used data types in JavaScript. They are used to store collections of data and allow for efficient access and manipulation of data. Arrays can contain any type of data, including primitive values, objects, and even other arrays. The technique of creating an array of partial objects from an array is a valuable technique when dealing with complex data sets. Partial objects contain only a subset of the data from the original array, allowing us to focus on a particular set of data. This can be especially useful when dealing with large data sets, ... Read More

Advertisements