Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I access directly to the second value of an array after .split()?

I have this code :

var tmp=$(this).attr('id').split("_");

and I'd like to store on tmp the second value after the split. So if $(this).attr('id') = "hello_marco" I'd like to store in tmp the value marco, not the array.

Of course, I want to do it directly in one line of code, without first store the array and the access to it with array[1].

Is it possible on JS/Jquery?

like image 369
markzzz Avatar asked Sep 12 '11 15:09

markzzz


1 Answers

var tmp = $(this).attr('id').split("_")[1];
like image 178
dertkw Avatar answered Oct 03 '22 21:10

dertkw