Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- html:
- <div class="lott-item"><img src="" class="img-bg</div>
- $(".lottery .lott-item").each(function() {
- var imgSrc = $(this).find(".img-bg").attr("src");
- $(this).parent().css("background", "url(" + imgSrc + ") no-repeat center center");
- $(this).parent().css("backgroundSize", "cover");
- $(this).css("display", "none");
- });
- $(".lottery .lott-item").hover(function() {
- var imgSrc = $(this).find(".img-bg").attr("src");
- $(this).css("background", "linear-gradient(rgba(0,0,0, .4), rgba(0,0,0, .4)), url(" + imgSrc + ") no-repeat center center");
- $(this).css("backgroundSize", "cover");
- }, function() {
- var imgSrc = $(this).find(".img-bg").attr("src");
- $(this).css("background", "linear-gradient(rgba(0,0,0, 0), rgba(0,0,0, 0)), url(" + imgSrc + ") no-repeat center center");
- $(this).css("backgroundSize", "cover");
- });
- $(document).on("load", function(){
- $(".lottery .lott-item").each(function() {
- var imgSrc = $(this).find(".img-bg").attr("src");
- $(this).parent().css("background", "url(" + imgSrc + ") no-repeat center center");
- $(this).parent().css("backgroundSize", "cover");
- $(this).css("display", "none");
- });
- $(".lottery .lott-item").hover(function() {
- var imgSrc = $(this).find(".img-bg").attr("src");
- $(this).css("background", "linear-gradient(rgba(0,0,0, .4), rgba(0,0,0, .4)), url(" + imgSrc + ") no-repeat center center");
- $(this).css("backgroundSize", "cover");
- }, function() {
- var imgSrc = $(this).find(".img-bg").attr("src");
- $(this).css("background", "linear-gradient(rgba(0,0,0, 0), rgba(0,0,0, 0)), url(" + imgSrc + ") no-repeat center center");
- $(this).css("backgroundSize", "cover");
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement