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

时间:2015-02-19 19:26:43

标签: javascript html css wordpress

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

搜索图标/图像位于菜单旁边(隐藏输入文本),点击同样显示包含所有菜单的输入文本。

我们正在使用wordpress,使用Hi-response主题。

提前致谢。

1 个答案:

答案 0 :(得分:1)

// 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.