6

I have an object with the id "4x153x9x10x173"and I need to parse the integer "153" from it into a variable using jquery?

objects.last().attr('id') // id = 4x153x9x10x173
3
  • Are you sure that desired value will always be after one x and before the second x? Commented May 12, 2012 at 20:35
  • @gdoron server side script add this value to html. think, it must be. any suggestions on how to check value when splitting for separator exists? Commented May 13, 2012 at 6:09
  • I couldn't understand your comment at all... :( Commented May 13, 2012 at 6:19

1 Answer 1

12
var desired = objects.last().attr('id').split('x')[1];

jsFiddle demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.