DOM background-Image add

I’m a beginner.

I encounter a small problem which is I cannot add an image to my div block.

here is my HTML code

<span class = 'memepic'>
<img src ="https://encryptedtbn0.gstatic.com/imagesq=tbn:ANd9GcTmvCGIVavqB6jVObiS1sqkvwlzYgpjCVfWBg&usqp=CAU">
</span>

and I wrote my js code is like this one

//it is my <span> id
const img = document.getElementsByClassName('memepic') 

//it is my divblock id
const memebox = document.querySelector('#meme')


for(i of img){
    i.addEventListener("click", function(e) {
        console.log(e)
        memebox.style.backgroundImage = 'url("e.path[0].currentSrc")';

      });
}

the error shows my console is

e.path[0].currentSrc:1 GET file:///C:/Users/kevin/Desktop/bootcamp/officialclass/meme%20generator/e.path[0].currentSrc net::ERR_FILE_NOT_FOUND

my purpose is when I click that picture, that picture will show on my divblock which is in the center of the screen.

I checked the path[0].currentSrc is correct.
and it will show the picture if I replace ‘e.path[0].currentSrc’ to the content inside the ‘e.path[0].currentSrc’.

like this

memebox.style.backgroundImage = 'url("https://encryptedtbn0.gstatic.com/imagesq=tbn:ANd9GcTmvCGIVavqB6jVObiS1sqkvwlzYgpjCVfWBg&usqp=CAU");

100 thoughts on “DOM background-Image add”

  1. Thanks for the marvelous posting! I definitely enjoyed reading it,
    you may be a great author. I will ensure that I bookmark your blog and
    will often come back later in life. I want to encourage that you continue your great writing, have a nice day!

    Reply
  2. Heya i am for the primary time here. I came across
    this board and I in finding It truly helpful & it helped me out a lot.
    I’m hoping to offer one thing again and aid others such as you aided me.

    Reply
  3. My coder is trying to convince me to move to .net
    from PHP. I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using Movable-type on numerous websites for about a year and
    am nervous about switching to another platform. I have heard fantastic things about blogengine.net.
    Is there a way I can transfer all my wordpress content into it?

    Any kind of help would be really appreciated!

    Reply
  4. What i don’t understood is if truth be told how you are
    now not really a lot more smartly-preferred than you might be now.
    You’re very intelligent. You recognize thus significantly with regards to this matter,
    produced me individually believe it from numerous various angles.
    Its like women and men are not interested unless it is something
    to do with Lady gaga! Your own stuffs excellent.
    At all times deal with it up!

    Reply
  5. Magnificent beat ! I would like to apprentice while
    you amend your website, how could i subscribe for a blog website?

    The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear idea

    Reply
  6. Heya i’m for the first time here. I found this board and I find It really useful & it helped me out much.
    I hope to give something back and aid others like you helped me.

    Reply
  7. Hi there! This article couldn’t be written any better!
    Reading through this post reminds me of my previous roommate!
    He constantly kept preaching about this. I am going to send this article to him.
    Fairly certain he’s going to have a great read.
    Many thanks for sharing!

    Reply
  8. Excellent article. Keep posting such kind of info on your blog.
    Im really impressed by your site.
    Hi there, You have done an excellent job. I’ll definitely digg it and individually suggest to my friends.
    I am sure they will be benefited from this web site.

    Reply