开发者

remove first char of a variable with jQuery

I'm trying to modify a jQuery variable from e.g. /images/tree.jpg to images/tree.jpg (without the first slash, so it should be a relative path instead of an absolute).

I get开发者_StackOverflow the URL like this: var href = jQuery("img.thumbnail").attr("href");

Now I need this URL on another place, but without the first char.

Is there an easy way to do this? Thanks!!


var href = jQuery('img.thumbnail').attr('href');  // e.g.  '#foo'
var secondCharacterAndOnward = href.substring(1); // e.g.  'foo'

String.substring

Though I'm not sure why an image tag has a href attribute, to be quite honest...


Use the javascript substring method.

var href = jQuery("img.Thumbnail").attr("href");
    href = href.substring(1);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜