If I use split, how to get the last array?
On 4月28日, 下午6時39分, Remon Oldenbeuving r.s.oldenbeuv...@gmail.com
wrote:
I dont think there's a real jQuery way, you could use regular
expressions, or maybe split the string with .split('/')
On 28 apr 2009, at 10:36, David .Wu chan1...@gmail.com
I got it, thanks everyone.
$('img').attr('src').split('/').pop();
On 4月28日, 下午6時39分, Remon Oldenbeuving r.s.oldenbeuv...@gmail.com
wrote:
I dont think there's a real jQuery way, you could use regular
expressions, or maybe split the string with .split('/')
On 28 apr 2009, at 10:36, David
i dont think there is actually a jQuery way.i think your best bet is
regular expression
but sorry i am not good at regular expression myself
but you can look at it and find your solution
This will only get you the first image filename in the document - to get all
of them, use something like this:
var filenames = [];
$('img').each(function(){
filenames.push($(this).attr('src').split('/').pop());
});
now filenames contains the filenames of all the images in the page
On Apr 28, 6:36 pm, David .Wu chan1...@gmail.com wrote:
img src=images/xxx.gif
$('img').attr('src') - This will get images/xxx.gif
How to get xxx.gif by jQuery?
img.src.replace(/.*\//, ''));
--
Rob
I dont think there's a real jQuery way, you could use regular
expressions, or maybe split the string with .split('/')
On 28 apr 2009, at 10:36, David .Wu chan1...@gmail.com wrote:
img src=images/xxx.gif
$('img').attr('src') - This will get images/xxx.gif
How to get xxx.gif by jQuery?
You could also do this:
$('img').attr('src').split('/').slice(-1);
-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of David .Wu
Sent: Tuesday, April 28, 2009 3:36 AM
To: jQuery (English)
Subject: [jQuery] How to get file name
img
7 matches
Mail list logo