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('#','');
精彩评论