Javascript Articles - Page 573 of 671

How to style background image to no repeat with JavaScript DOM?

Abhishek
Updated on 25-Nov-2022 06:45:05

3K+ Views

In this tutorial, we will learn to style the background image to no repeat with JavaScript DOM. To style the background image to no repeat with JavaScript, use the backgroundRepeat property. It allows you to set whether the background image repeats or not on a page. The use of images in the background really makes the page attractive. But before using the image in the background, one must need completely understand the properties used to set the images as the background. Otherwise, it will create problems for you like not showing the full image in the background, repeating the image ... Read More

How to set the starting position of a background image in JavaScript DOM?

Sharon Christine
Updated on 23-Jun-2020 10:00:38

515 Views

To set the starting position of a background image in JavaScript, use the backgroundposition property. It allows you to set the position of the image.ExampleYou can try to run the following code to learn how to set all the position of a background image with JavaScript −Live Demo                    body {             background-repeat: no-repeat;          }                     Click to Set background image                function display() {             document.body.style.backgroundImage = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg')";             document.body.style.backgroundPosition="top right";          }          

How to return the background color of an element with JavaScript DOM?

Prabhdeep Singh
Updated on 07-Nov-2022 07:40:37

4K+ Views

In this tutorial, we will explore the method by which we can get the background color of an element with JavaScript. There are many scenarios where we may want to get the color of an element on the page, and we will see how to achieve that easily using inbuilt methods provided by JavaScript. We cannot only retrieve the color of the color we can also set the color of an element using the same function. To achieve this, we will be using a modification of the same function. Browser Support Chrome Browser − Version 1.0 and above. Edge ... Read More

What will happen when 1 is converted to Boolean in JavaScript?

Paul Richard
Updated on 23-Jun-2020 09:20:39

135 Views

You can try to run the following code to learn how to convert 1 to Boolean in JavaScript −ExampleLive Demo           Convert 1 to Boolean                var myVal = 1;          document.write("Boolean: " + Boolean(myVal));          

How to get the hash part of the href attribute of an area in JavaScript?

Shubham Vora
Updated on 14-Sep-2022 13:28:28

739 Views

In this tutorial, we will learn how to get the hash part of the href attribute of an area in JavaScript. The HTML element establishes an area within an image map with predetermined clickable zones. An image map allows you to correlate geometric regions of a picture with hypertext links. This element can only be used within the < map> element. The href property gives the area's hyperlink target. The element is not a hyperlink if the href attribute is not present. Following is a method used to get the href attribute’s hash part of an area in ... Read More

How to set a background image to be fixed with JavaScript DOM?

Rishi Raj
Updated on 23-Jun-2020 09:21:58

654 Views

To set the background image to be fixed in JavaScript, use the backgroundAttachment property. It allows you to set an image that won’t scroll.ExampleYou can try to run the following code to learn how to work with backgroundAttachment property with JavaScript −Live Demo           Click to Set background       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text     ... Read More

What will happen when 0 is converted to Number in JavaScript?

karthikeya Boyini
Updated on 23-Jun-2020 09:22:27

113 Views

Use the Number() method in JavaScript to convert to Number. You can try to run the following code to learn how to convert 0 to Number in JavaScript −ExampleLive Demo           Convert 0 to Number                var myVal = 0;          document.write("Number: " + Number(myVal));          

How to search the querystring part of the href attribute of an area in JavaScript?

Ramu Prasad
Updated on 23-Jun-2020 09:23:07

153 Views

To get the querystring of the href attribute of an area, use the search property. You can try to run the following code to search the querystring −Example                                                var x = document.getElementById("myarea").search;          document.write("Querystring: "+x);          

How to set all the background properties in one declaration with JavaScript DOM?

Swarali Sree
Updated on 23-May-2020 11:41:14

144 Views

To set the background in JavaScript, use the background property. It allows you to set the background color, image, position, etc.ExampleYou can try to run the following code to learn how to set all the background properties in a single declaration with JavaScript.Live Demo           Click to Set background                function display() {             document.body.style.background = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg') repeat right top";          }          

How to search and display the pathname part of the href attribute of an area with JavaScript?

Vrundesha Joshi
Updated on 23-May-2020 11:37:05

164 Views

To get the pathname part of the href attribute of an area in JavaScript, use the pathname property.ExampleYou can try to run the following code to display the pathname part.                                                var x = document.getElementById("myarea").pathname;          document.write("Pathname: "+x);          

Advertisements