Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. html:
  2. <div class="lott-item"><img src="" class="img-bg</div>
  3.  
  4. $(".lottery .lott-item").each(function() {
  5. var imgSrc = $(this).find(".img-bg").attr("src");
  6. $(this).parent().css("background", "url(" + imgSrc + ") no-repeat center center");
  7. $(this).parent().css("backgroundSize", "cover");
  8. $(this).css("display", "none");
  9. });
  10.  
  11. $(".lottery .lott-item").hover(function() {
  12. var imgSrc = $(this).find(".img-bg").attr("src");
  13. $(this).css("background", "linear-gradient(rgba(0,0,0, .4), rgba(0,0,0, .4)), url(" + imgSrc + ") no-repeat center center");
  14. $(this).css("backgroundSize", "cover");
  15. }, function() {
  16. var imgSrc = $(this).find(".img-bg").attr("src");
  17. $(this).css("background", "linear-gradient(rgba(0,0,0, 0), rgba(0,0,0, 0)), url(" + imgSrc + ") no-repeat center center");
  18. $(this).css("backgroundSize", "cover");
  19. });
  20.  
  21. $(document).on("load", function(){
  22. $(".lottery .lott-item").each(function() {
  23. var imgSrc = $(this).find(".img-bg").attr("src");
  24. $(this).parent().css("background", "url(" + imgSrc + ") no-repeat center center");
  25. $(this).parent().css("backgroundSize", "cover");
  26. $(this).css("display", "none");
  27. });
  28.  
  29. $(".lottery .lott-item").hover(function() {
  30. var imgSrc = $(this).find(".img-bg").attr("src");
  31. $(this).css("background", "linear-gradient(rgba(0,0,0, .4), rgba(0,0,0, .4)), url(" + imgSrc + ") no-repeat center center");
  32. $(this).css("backgroundSize", "cover");
  33. }, function() {
  34. var imgSrc = $(this).find(".img-bg").attr("src");
  35. $(this).css("background", "linear-gradient(rgba(0,0,0, 0), rgba(0,0,0, 0)), url(" + imgSrc + ") no-repeat center center");
  36. $(this).css("backgroundSize", "cover");
  37. });
  38. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement