Getting a substring using jquery
I want to make a little gallery and add next/previous buttons. I managed to trim down the urls of the pictures to something like this : 30052010/30052010001 . So the pi开发者_如何学JAVActure is 30052010001.jpg and the next one is 30052010002.jpg .However how can i remove the first part of the string(the folder name) and the last digits from the end of the string so that i can auto-increment a variable and change to the next picture ? Thanks.
You can do it with only Javascript like this:
var x = "30052010/30052010001";
y = x.split('/');
alert(y[1]+'.jpg');
You can use split function
var filename = '30052010/30052010001';
var parts = filename.split('/');
var newFilename= (parts[0] + "/" + ++ (parts[1])); // '30052010/30052010002'
精彩评论