Changing img src through jQuery: image won't refresh

后端 未结 1 1896
轮回少年
轮回少年 2021-01-21 01:31

I\'m trying to change src dynamically through jquery in a Phonegap Build application, like this

$(\'#photo_profile\').attr(\'src\', fullPath).one(\"load\", func         


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-21 02:08

    Sounds like caching issue. Try to prevent it with some random parameter:

    $('#photo_profile').prop('src', fullPath + '?' + Math.random())
    

    Also src is a property, so it makes sense to use prop instead of attr.

    0 讨论(0)
提交回复
热议问题