Home > Web Front-end > JS Tutorial > Get the background-image attribute of div through js_javascript skills

Get the background-image attribute of div through js_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:20:11
Original
2167 people have browsed it

I haven't paid attention to the background-image attribute of the div before. I just set its URL. I encountered a problem today and I will record it here.

Copy code The code is as follows:



in js I want to get the image attribute
Copy the code The code is as follows:

document.getElementById('img_2' ).style.backgroundImage;

Pay attention to the bold part, the div is background-image, and the attribute is backgroundImage. This should be done for all styles with "-". This needs to be verified.

Record this issue first to learn.
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Float a div inside another div
From 1970-01-01 08:00:00
0
0
0
javascript - div carousel issue
From 1970-01-01 08:00:00
0
0
0
Div captures mouse scroll
From 1970-01-01 08:00:00
0
0
0
How to make a div appear below another div in CSS
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template