Get URL from background-image Property

后端 未结 1 1260
陌清茗
陌清茗 2020-12-01 17:16

i am currently using this to get the url from the background-image property:

var url = $(this).find(\'div\').css(\'background-image\');
url = url.substr(4, u         


        
相关标签:
1条回答
  • 2020-12-01 17:57

    You could do:

    url = url.replace(/^url\(["']?/, '').replace(/["']?\)$/, '');
    

    This will remove url(' and url(" from the beginning of the string if it is present and ") resp. ') from the end.

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