[jQuery] Re: Working with text

2008-06-16 Thread andrea varnier
On 15 Giu, 14:55, "Ariel Flesler" <[EMAIL PROTECTED]> wrote: > var n = +"forum-list-1".slice(-1); ;-) I think this won't work if the number has 2 or more digits. The split('-').pop() way works better imho :)

[jQuery] Re: Working with text

2008-06-15 Thread yo2lux
var n = this.parentNode.parentNode.id ; // return: forum-list-x (x is an integer). I use this statement to extract the number: var n = this.parentNode.parentNode.id.slice(11); I think this is the good solution!! On Jun 15, 6:56 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote: > Aaargh, can somebody

[jQuery] Re: Working with text

2008-06-15 Thread yo2lux
Sorry, I need the number (marked with x): forum-list-x and not the string before the number. On Jun 15, 3:55 pm, "Ariel Flesler" <[EMAIL PROTECTED]> wrote: > var n = +"forum-list-1".slice(-1); ;-) > > -- > Ariel Fleslerhttp://flesler.blogspot.com > > On 6/15/08, Klaus Hartl <[EMAIL PROTECTED]

[jQuery] Re: Working with text

2008-06-15 Thread Klaus Hartl
Aaargh, can somebody please stop Ariel ;-) --Klaus On 15 Jun., 14:55, "Ariel Flesler" <[EMAIL PROTECTED]> wrote: > var n = +"forum-list-1".slice(-1);   ;-) > > -- > Ariel Fleslerhttp://flesler.blogspot.com > > On 6/15/08, Klaus Hartl <[EMAIL PROTECTED]> wrote: > > > > > > > And in case you want

[jQuery] Re: Working with text

2008-06-15 Thread Ariel Flesler
var n = +"forum-list-1".slice(-1); ;-) -- Ariel Flesler http://flesler.blogspot.com On 6/15/08, Klaus Hartl <[EMAIL PROTECTED]> wrote: > > > And in case you want to shorten the parseInt: > > var n = +"forum-list-1".split('-').pop(); > > --Klaus > > > On 15 Jun., 14:24, Klaus Hartl <[EMAIL PROT

[jQuery] Re: Working with text

2008-06-15 Thread Klaus Hartl
And in case you want to shorten the parseInt: var n = +"forum-list-1".split('-').pop(); --Klaus On 15 Jun., 14:24, Klaus Hartl <[EMAIL PROTECTED]> wrote: > var n = parseInt(/\d/.exec("forum-list-1")[0]); > > Or even easier using split (if you can rely on the format of the > string) - pretty mu

[jQuery] Re: Working with text

2008-06-15 Thread Klaus Hartl
var n = parseInt(/\d/.exec("forum-list-1")[0]); Or even easier using split (if you can rely on the format of the string) - pretty much what Ariel already showed: var n = parseInt("forum-list-1".split('-').pop()); --Klaus On 15 Jun., 13:18, yo2lux <[EMAIL PROTECTED]> wrote: > Thanks and which

[jQuery] Re: Working with text

2008-06-15 Thread yo2lux
Thanks and which is the best way to obtain the last number of string, for example I have: forum-list-1 forum-list-2 forum-list-3 I need the numbers: 1, 2 or 3. On Jun 12, 6:44 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote: > And that's why Ariel is da man! Nice one. > > --Karl > > Ka

[jQuery] Re: Working with text

2008-06-12 Thread Karl Swedberg
And that's why Ariel is da man! Nice one. --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Jun 12, 2008, at 7:09 AM, Ariel Flesler wrote: Ooor var fileName = $('img').attr('src').split('/').pop(); Cheers :) -- Ariel Flesler http://flesler.blogspo

[jQuery] Re: Working with text

2008-06-12 Thread Andrew
var path = $('img').attr('src').replace(/.*\//, ''); Actually, I like Ariel's solution better as it's more readable. I just have a personal compulsion to solve every problem with regex. On Jun 11, 4:36 pm, yo2lux <[EMAIL PROTECTED]> wrote: > path variable store the following: /themes/mytheme/

[jQuery] Re: Working with text

2008-06-12 Thread Ariel Flesler
Ooor var fileName = $('img').attr('src').split('/').pop(); Cheers :) -- Ariel Flesler http://flesler.blogspot.com/ On 11 jun, 22:29, Karl Swedberg <[EMAIL PROTECTED]> wrote: > Hi there, > > You could do it like this: > > var path = $('img').attr('src'); > var fileName = path.slice(pat

[jQuery] Re: Working with text

2008-06-11 Thread Karl Swedberg
Hi there, You could do it like this: var path = $('img').attr('src'); var fileName = path.slice(path.lastIndexOf('/')+1); --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Jun 11, 2008, at 7:36 PM, yo2lux wrote: path variable store the following: /themes