[jQuery] Re: How to get file name
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 wrote: img src=images/xxx.gif $('img').attr('src') - This will get images/xxx.gif How to get xxx.gif by jQuery?
[jQuery] Re: How to get file name
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 .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?
[jQuery] Re: How to get file name
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
[jQuery] Re: How to get file name
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 David .Wu wrote: 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 .Wu chan1...@gmail.com wrote: images/xxx.gif $('img').attr('src') - This will get images/xxx.gif How to get xxx.gif by jQuery? -- View this message in context: http://www.nabble.com/How-to-get-file-name-tp23272719s27240p23275342.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: How to get file name
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
[jQuery] Re: How to get file name
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?
[jQuery] Re: How to get file name
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 src=images/xxx.gif $('img').attr('src') - This will get images/xxx.gif How to get xxx.gif by jQuery?