-5

I need to get the length of an inline style background-image source, eg:

<div id="imageholder" style="background-image: url(image.jpg)">

Length would be 9

I have tried:

$('#imageholder').css('background-image').length;

But I cant seem to get it working.

Would anyone know the proper way of getting this length?

MeltingDog
  • 12,714
  • 38
  • 143
  • 270

1 Answers1

1

You need to use:

$('#imageholder').css('background-image').replace('url(','').replace(')','').length;

regex used from Blazemonger answer

Community
  • 1
  • 1
Milind Anantwar
  • 79,642
  • 23
  • 92
  • 120