How To Get Background Image Url In Jquery - How To Get

Animate background color in jQuery Example Demo

How To Get Background Image Url In Jquery - How To Get. This is an inbuilt method in jquery to add the css property but in this case, we need to provide complete property using the url() method. You might want to strip out the 'url ()' part too:

Animate background color in jQuery Example Demo
Animate background color in jQuery Example Demo

Leave a comment on cideveloper's reply. $ (#img1).attr ('src', string.match (/.*url\ ( ['|] ( [^)]*) ['|]\)/i)); Return imageurl.replace (/ (url\ (|\)|'|)/gi, ''); // display the url to the user alert ('image. You can achieve this task by using the css() method in jquery. Then we can get the value of the. You can use the below code for getting the background image in jquery. For instance, if we have the following html: // get background image using css property bg = bg.replace('url(','').replace(')',''); This is required result but want to achieve the same without getting by id:

This is required result but want to achieve the same without getting by id: You can use the below code for getting the background image in jquery. Then we can get the value of the. Return imageurl.replace (/ (url\ (|\)|'|)/gi, ''); You can achieve this task by using the css() method in jquery. This is all the code you need: // display the url to the user alert ('image. This is required result but want to achieve the same without getting by id: This is an inbuilt method in jquery to add the css property but in this case, we need to provide complete property using the url() method. $ (#img1).attr ('src', string.match (/.*url\ ( ['|] ( [^)]*) ['|]\)/i)); Function getbackgroundimageurl ($element) { if (!