Sunday, August 30, 2009

[jQuery] Re: Dissect an ID

There may be a more elegant way, but until it comes along...

you can .split() the string on the _ character.

myArray = myString.split('_')

which in your case would create an array with element 'thisisadiv' at position 0, and '1' at position 1.

you could then reference it via myArray[1]

On Sun, Aug 30, 2009 at 3:29 PM, Phil <pjwhitehead93@googlemail.com> wrote:

In jQuery how do I remove a certain part of an id...

for example i have a div id='thisisadiv_1'
I want to remove the 'thisisadiv_' part
This is so I can add/subtract 1 to switch divs.

Thanks in Advance.
Phil.



--
I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.

No comments: