您的位置:首页 > Web前端 > HTML

html超链接href设置技巧和动态创建页面元素技巧

2011-04-29 17:46 351 查看
1.

如果<a />的href不能设置连接时可以如下处理

<a href="javascript:;" onclick="clickFn()" >click here</a>

用javascript:;代替#则不会出现在点击了超链接后页面跳到页顶部的情况

2.

var prePage=document.createElement("a");

prePage.href="javascript:;";

prePage.value=this.prePage;

prePage.onclick=function(){};

prePage.appendChild(document.createTextNode("上一页 "));

document.getElementById("div1").appendChild(prePage);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: