How To Get Background Image Url In Jquery - How To Get
Get, Set and Delete Div Background Image jQuery Tuts Make
How To Get Background Image Url In Jquery - How To Get. // display the url to the user alert ('image. You might want to strip out the 'url ()' part too:
Get, Set and Delete Div Background Image jQuery Tuts Make
Then we can get the value of the. You can use the below code for getting the background image in jquery. And here's a demonstration (using the same regex, but different code to better illustrate the process): ($element instanceof jquery)) { $element = $ ($element); Function getbackgroundimageurl ($element) { if (! // get background image using css property bg = bg.replace('url(','').replace(')',''); You can achieve this task by using the css() method in jquery. This is required result but want to achieve the same without getting by id: For instance, if we have the following html: // strip everything but the url itself } share.
In simple words, we need to create an empty div and on click event, the empty div will get the image as a background. You might want to strip out the 'url ()' part too: // get background image using css property bg = bg.replace('url(','').replace(')',''); Leave a comment on cideveloper's reply. // strip everything but the url itself } share. This is required result but want to achieve the same without getting by id: // display the url to the user alert ('image. For instance, if we have the following html: And here's a demonstration (using the same regex, but different code to better illustrate the process): 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));