Is there a better way to change the cursor? Am I doing it right?
I was just using some javascript the other day, and previously, the only way I knew how to get it to display the cursor was to do this:
1:
<a href="javascript:" onClick="myfunction()"></a>
But I decided to find some other ways to do it. Not wanting to have my css messy and all over the place, I added this to my stylesheet:
2:
a{
cursor:pointer
}
I'm not styling non-link anchors anywhere else. Is it okay to style non-link anchors?
3:
Or is there a way I should b开发者_Python百科eing doing it with javascript that's better then the two ways listed above.
Hey some browsers call the cursor a pointer, others call it a hand (forgot which ones which). So what you have to do is
.pointable
{
cursor: pointer;
cursor: hand;
}
Edit:
I like to make a css style called pointable and applying it to whatever elements I want pointable.
<div class="box pointable rounded">dggf</div>
<a class="pointable">sdds</a>
As long as this does not get in the way of how you style the <a>
tag anywhere else on your page this is the best way to do it.
All <a>
tags should have an href
attribute even if it is blank or says javascript:;
.
So I recommend option 1.
精彩评论