-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
  • 14,310
  • 43
  • 165
  • 295

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
  • 81,290
  • 25
  • 94
  • 125