README
Jquery BG Image JS
Retorna a imagem de background de qualquer elemento como um objeto. | Returns the background image of any element as an object.
Godahtech | Soluções Digitais - Roberto Godoy
Version 1.0.0Zero Vulnerabilidades
Instalação
npm i jquery-bg-image --save
Usando:
HTML
<div id="bg-image"></div>
CSS
#bg-image {
width: 100%;
height: 100%;
background-size: cover;
background-position: center top;
background-image: url(harley-quinn.jpg);
}
JAVASCRIPT
$(document).ready(function () {
$("#bg-image").bgImage(function (event) {
/**
* Event Log
*/
console.log(event);
/**
* Get Object
* @type {*|jQuery}
*/
var background_image = $(this).get(0);
/**
* Get width
*/
console.log(background_image.width);
/**
* Get height
*/
console.log(background_image.height);
/**
* Get src
*/
console.log(background_image.src);
});
});