JSFiddle - React, Tailwind, and code Playground
by JInks Peng
HTML
<input type='text' id='hit'/>
<button type='button' id='btn'>禁止输入</button>
JavaScript
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();
}
}
}