问题
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
回答1:
var current = $(this).attr('href').slice(1);
alert(current);
回答2:
I assume you're dealing with a <a>
element?
this.hash.substring(1); // yes, it's that simple...
回答3:
As easy as this, just use replace
:
var current = $(this).attr('href').replace('#','');
来源:https://stackoverflow.com/questions/3156077/remove-from-value-jquery