window.onload = function() { var hit = document.getElementById('hit'), btn = document.getElementById('btn'); btn.onclick = function() { //hit.disabled = true; hit.readOnly = true; hit.style.cursor='not-allowed'; hit.onfocus = function() { this.blur(); } } }
<input type='text' id='hit'/> <button type='button' id='btn'>禁止输入</button>