jQuery get the image src

前端 未结 6 958
醉梦人生
醉梦人生 2020-12-04 16:29

I hope when I click the button, I can get the specific img src and show the img src in the div class img-block block.

HTML



        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 16:39

    for full url use

    $('#imageContainerId').prop('src')
    

    for relative image url use

    $('#imageContainerId').attr('src')
    

    function showImgUrl(){
      console.log('for full image url ' + $('#imageId').prop('src') );
      console.log('for relative image url ' + $('#imageId').attr('src'));
    }
    
    
    
    

提交回复
热议问题