我有一个代码,以改变标题时,按下搜索按钮,这部分工作。
function searchButtonAction() {
if (isSubmit()) {
document.getElementById('search-box').submit();
} else {
showSearch();
noShowMenuLogo();
function clf() {
if (!searchInProgress) {
noShowSearch(); showMenuLogo();
} else {
setTimeout(clf, 25)
}
}
sia = setInterval(() => {
if (searchInProgress) {
clearInterval(sia);
setTimeout(clf, 25);
}
}, 25);
}
}但出于某种原因当我这么做时
function noShowSearch() {
document.getElementById('search-text').style.display = 'none';
document.getElementById('search-text').style.width = '';
document.getElementById('clear-search').style.display = 'none';
document.getElementById('search-box').style.backgroundColor = 'none';
document.getElementById('search-box').style.border = 'none';
document.getElementById('search-box').style.width = '';
document.getElementById('left-items-box').style.width = '';
}搜索框的背景色不变
我想要的结果是:

我得到的结果是:

解决方案在注释中.
发布于 2021-04-30 08:40:14
background-color: none;是无效的属性值。可能使用:document.getElementById('search-box').style.backgroundColor = 'transparent';
https://stackoverflow.com/questions/67330423
复制相似问题