Problem with href attribute in named anchors

October 30th, 2013 by Nik

Sometimes even the simplest things in life that we always took for granted seems to give us a kick on our backside. That is when we get to learn little lessons of life. The simplest piece of code that always worked like charm, fails to work, Today was just that day. I had an issue with a named anchor which I had defined to add a Jquery Smooth Scroll. The scroll to an anchor just failed to work … thankfully it was a very simple fix.

The code that I had (when the named anchor did not work) 
<a href="" id=”a_rate_this”></a> 
Got fixed when , I replaced the above with  
<a href=”javascript:void(0);” id=”a_rate_this”></a>
Or even just remove the href attribute as below
<a id=”a_rate_this”></a>
yeah! but in this case you will loose the default pointer cursor 
of the anchor tag and it will change to cursor of type text.
You could solve this issue with a css fix,
i.e. by adding cursor:pointer to the anchor tag.

Tags:


get ExpressingIT News by Email Subscribe to ExpressingIT by Email |  Follow Me on Twitter


Leave a Reply

 Subscribe to ExpressingIT RSS
get ExpressingIT News by Email Subscribe to ExpressingIT by Email
 Follow Me on Twitter