开发者

is it possible to use href and javascript:void both in <a> tag?

is it possible to have

<a href="index.php" > click </a> 

that doesn't change page location on click on link? i know that 'javascript:开发者_如何转开发void(0);' should be used if we don't want the location change on click,but i need to determine the link href to be used in some jquery codes.


You can make the onclick javascript event of your link to return false. It will do what you want.


You can return false from a click handler to prevent navigation.


you can do following:

myElement.onclick = function(event){
  event.preventDefault();
  //now you can use href attribute
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜