Set image src to another image jquery

后端 未结 3 1147
深忆病人
深忆病人 2020-12-17 08:33

I have a div with some images, and when I clicked on those images I want another div to open with that Image that I clicked.

JS

$(\'         


        
相关标签:
3条回答
  • 2020-12-17 09:14

    change line 3 to reference the image instead of its container:

    $('#image-zoom img').attr("src",loc);
    
    0 讨论(0)
  • 2020-12-17 09:29

    #image-zoom is an id for a div tag, which doesn't have a src attribute. So in order to change the image you've to traverse to img:

    $('#image-zoom img').attr("src",loc);
    
    0 讨论(0)
  • 2020-12-17 09:31

    Change the src of the image, not of the div:

    $('#image-zoom img').attr("src",loc);
    
    0 讨论(0)
提交回复
热议问题