How do I style a span to look like a link without using javascript?

后端 未结 9 1419
慢半拍i
慢半拍i 2021-02-02 06:00

For my website I will need to use instead of , because I am using mostly ajax and thus instead of links I have onclick ajax event

9条回答
  •  南方客
    南方客 (楼主)
    2021-02-02 06:17

    Note that if your website is public and you are counting on search engines to crawl your site, you lose a lot by leaving out links without href since spiders have nothing to grab on while crawling your page.

    You should use a complete link - in case your javascript breaks down the user is still able to navigate through pages:

    Link
    

    than you can disable the link with jquery by using preventDefault() - and you totally separated base html and the javascript part, meaning your site is still usable without javascript on.

    Than you don't need to bother with span hover and anything - but just for the sake of it

    span:hover {
    cursor:pointer;
    }
    

    will enable hover hand cursor on hovered span.

提交回复
热议问题