gpt4 book ai didi

javascript - 如何在向下滚动事件中更改输入文本的颜色

转载 作者:太空宇宙 更新时间:2023-11-04 12:17:13 25 4
gpt4 key购买 nike

在我的网站上,我在每个页面顶部都有白色的搜索框,我想将搜索框的颜色更改为与正文页面的背景颜色相同。每个页面都有自己的背景颜色。

搜索图标/图像在菜单旁边(输入文本被隐藏),单击它会显示覆盖所有菜单的输入文本。

我们使用的是wordpress,使用的是Hi-response主题。

提前致谢。

最佳答案

// Not Tested
<script>
$(window).scroll(function(){
if(document.getElementById("searchBar");.scrollTop() > 10){
document.getElementById("searchBar").style.color = "Red"
}
else {
document.getElementById("searchBar").style.color = "Blue"
}
});
</script>

编辑:

背景和搜索栏使用相同的id。

<style>
#pageTheme {
background-color:red;
}
</style>
<body class="bodyTheme" id="pageTheme">
<div class="searchBarTheme" id="pageTheme">SearchBar Stuff</div>
</body>
ID overrides class, so the background color of pageTheme will be projected inherited by both.

关于javascript - 如何在向下滚动事件中更改输入文本的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28615140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com