Guest User

Untitled

a guest
Sep 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <div class="class1" style="background-image:url(https://www.awebsite.com/sites/default/files/a_image.jpg?t=1529620960)"></div>
  2.  
  3. https://www.awebsite.com/sites/default/files/a_image.jpg?t=1529620960`
  4.  
  5. https://hello.com/an-other-image.jpg
  6.  
  7. c = document.getElementsByClassName('class1');
  8. for(i = 0; i < c.length; i++){
  9. c[i].style.backgroundImage = 'url(https://hello.com/an-other-image.jpg)';
  10. }
  11.  
  12. // querySelector can use CSS selectors to find the element in the document
  13. // note: this is assuming there is only 1 element on page with this class
  14. var myDiv = document.querySelector('.class1');
  15. // Style properties generally match CSS but camel cased
  16. myDiv.style.backgroundImage = 'url("https://hello.com/an-other-image.jpg");
Add Comment
Please, Sign In to add comment