我有一个表格。其中我有一个文本区域,单击时会展开。 但有一个小问题: 当用户尝试提交表单(单击提交按钮)时,文本区域会跳回其正常大小。这是因为它使用了 onblur 函数。我想消除这种尴尬,因为用户必须单击提交按钮两次才能提交表单。
我应该怎样做才能使其一键运行?
最佳答案
您可以在 onblur 处理程序中设置一个较短的超时来缩小文本区域:
document.getElementById("textareaID").onblur = function () {
var target = this;
setTimeout( function () {
//Code to shrink the textarea, use "target" instead of "this" for scoping reasons.
}, 250);
}
关于javascript - 我该如何解决这个 onclick-onblur 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7177194/