頁面就是這么簡單!為啥a標簽點擊后滾動條會滾到頁面頂端?<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>jshint</title> <style type="text/css"> body{ height:1500px; } #fill{ width:1000px; height:1000px; } #a{ display: block; width:300px; height:30px; border:5px solid black; } </style></head><body><div id="fill"></div><a href="" id="a">點我改變邊框顏色</a><script type="text/javascript"> document.getElementById('a').onclick = function () { this.style.cssText = 'border:5px solid red;' };</script></body></html>
點擊頁面底部的a標簽為啥滾動條會滾到頁面頂端?
蕭十郎
2018-09-07 13:16:12