开发者

jquery ajax parse xml, split array

开发者 https://www.devze.com 2022-12-27 09:21 出处:网络
开发者_StackOverflow中文版is it possible to get the last value of an string, that looks like this for example:

开发者_StackOverflow中文版is it possible to get the last value of an string, that looks like this for example:

tm="1610612741|Bulls|Chicago|CHI"

and save it as a variable?

Something like that:

var tm = $(this).find('htm').attr('tm');

I only need the "CHI" string. I tried everything, but what i found doesnt work. I get the string and the var from an xml file. Also is it possible to parse the xml from a "live" version, like http://www.exampledomain.com/test.xml?

Appreciate your help!

Nicole


var tm = '1610612741|Bulls|Chicago|CHI';
var arr = tm.split('|');
var lastPart = arr[arr.length - 1];

alert(lastPart); // CHI
0

精彩评论

暂无评论...
验证码 换一张
取 消