日期:2014-05-17 浏览次数:20841 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<a href="http://www.google.com/" id="demo">GOOGLE</a><button id="btn_enable">Enable</button><button id="btn_disable">Disable</button>
<script type="text/javascript">
var demo = document.getElementById('demo');
document.getElementById('btn_enable').onclick = function() {
demo.style.color = '';
demo.onclick = null;
}
document.getElementById('btn_disable').onclick = function() {
demo.style.color = '#CCC';
demo.onclick = function() {
return false;
}
}
</script>
</body>
</html>
------解决方案--------------------
页面加载成功后,把a的href属性删除
或者
禁止a的默认事件。
------解决方案--------------------
没看到你要什么效果……,直接href='#'不行?