2.9 改进链接

  • 前往链接时,提示用户;
  • this 会根据上下文传递相应的对象;
<a id="a" href="https://www.baidu.com">搜索</a>

<script>
    document.getElementById("a").onclick = function () {
        alert("确定前往" + this);
        return true;
    }
</script>