当我专注于输入时,我想“禁用” Javascript函数。禁用可能是一个错误的术语,但我只是想停止某个功能的工作。除了dislable.
以外,我还有以下类似的想法。
input = document.getElementById("input");
if (input.focus()) {
disable.expand();
}
function expand() {
const gridItems = document.querySelectorAll(".grid-item");
const collapsings = document.querySelectorAll(".collapsing");
for (let i = 0; i < gridItems.length; i++) {
gridItems[i].addEventListener("mouseenter", () => {
gridItems[i].style.width = "400px";
collapsings[i].style.maxHeight = collapsings[i].scrollHeight + "px";
});
gridItems[i].addEventListener("mouseleave", () => {
gridItems[i].style.width = null;
collapsings[i].style.maxHeight = null;
});
}
}
这样可能吗?