创建< a>的最佳方法链接与空href [英] Best way to create an <a> link with empty href

查看:89
本文介绍了创建< a>的最佳方法链接与空href的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < p>< p> ; a id =ServerSorthref =#style =text-decoration:underline> 

它运行良好,但点击后页面将会丢失当前位置。 < a> 链接。



我需要链接有一个href,因为我需要鼠标在浏览时更改光标?
$ b $你可以使用 javascript:void(0)

code>

 < a id =ServerSorthref =javascript:void(0)> 

你不需要 style =text-decoration:underline,由 King King 评论



<通过jQuery,你可以通过 event.preventDefault()
$ b


停止事件的默认操作。




  $('#ServerSort')。click(function(event){
event.preventDefault(); //或返回false;
}) ;


I want to create a link , and to force the link anchor using javaScript, i tried the following:-

<a id="ServerSort" href="#" style="text-decoration:underline">

it worked well but the page will loose its current position after clicking on the <a> link.

I need the link to have an href, because i need need the mouse to change the cursor when going over it ?

can anyone advice ?

解决方案

You can use javascript:void(0)

<a id="ServerSort" href="javascript:void(0)">

you don't need style="text-decoration:underline" as commented by King King


by jQuery you can do it by event.preventDefault()

Stop the default action of the event .

$('#ServerSort').click(function(event){
   event.preventDefault(); //or return false;
});

这篇关于创建&lt; a&gt;的最佳方法链接与空href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆