如何使文本框 blurred/disabled 成为焦点

How to make a textbox blurred/disabled on focus

当文本框使用 JavaScript 获得焦点时,如何在不使用 disabledreadonly 的情况下处理 disabling/blurring 文本框?

认为这就是你根据问题试图实现的目标:

var fname = document.getElementById('fname');

fname.addEventListener('focus', function() {
  this.blur();
})
Name: <input type="text" name="fname" id="fname" />

您可以为文本框设置 CSS class。例如:

HTML:

class="blurTextbox"

CSS:

.blurTextbox:focus{
  pointer-events:none;
  opacity:0.5;
}

您可以在 Google 上查找其他想要的模糊效果;我想你会找到一些不错的。