开发者

Remove # from value (jQuery)

var current = $(this).attr('href');
alert(current);

shows the value with '#' eg '#target' instead of just 'target',开发者_运维知识库 what do I modify in the code?

Thanks


var current = $(this).attr('href').slice(1);
alert(current);


I assume you're dealing with a <a> element?

this.hash.substring(1); // yes, it's that simple...


As easy as this, just use replace:

var current = $(this).attr('href').replace('#','');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜