jquery - Javascript get element background image BUT eliminate the "url()" -
ive been working on image gallery ive been creating myself , im adding "zoom in" feature it.
i know im close succeeding have 1 tiny issue. in javascript managed background property of image enlarged grabs image including url()
. want url (http:.../) excluding url()
.
i hope isn't confusing if are, link project. click on image zoom in, alerts background-image
property because wanted see fetches first.
is possible?
the simple solution slice method. first parameter specifies start selection, second specifies end selection end of string if it's negative. so, code should be:
var bkimg = window.getcomputedstyle(sourceimg,null).getpropertyvalue("background-image"); var bkimgurl = bkimg.slice(4, -1);
Comments
Post a Comment