1.0.0 • Published 4 years ago

jquery-bg-image v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Jquery BG Image JS

Zero Vulnerabilidades

Known Vulnerabilities

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);
    
    });
    
});