Reputation: 2303
I have a background image for a div, I would like to get the background image name alone using jquery.
i am getting 'http://localhost/xampp/uconnect/images/tour-networks-ss.png'
but i need only 'tour-networks-ss.png'
please help me in this
Upvotes: 2
Views: 2962
Reputation: 32158
there are many ways to achieve maybe .split()
is the shortest :)
splitted = url.split('/');
filename = splitted[splitted.length -1]
edit: it event can be done on one row:
image = url.split('/').pop();
Upvotes: 11