HI,
For a tag, you can execute javascript through href or onclick.
When should I use onclick instead of href?
for me, only advantage I get with oncli
Ideally you won't use either. Ideally your link is a normal hyperlink with an href
value referencing a fragment (#foo
) or URL. Ideally the link would just work as-is without Javascript, too.
You'd then use unobtrusive Javascript that attaches itself to links or other DOM elements as needed and only if Javascript is available:
Do some action!