如何在jquery中插入背景图像?

时间:2016-04-26 10:41:24

标签: jquery html

我需要帮助,这是我的代码,我搜索了很多,但我找不到任何适合我的东西。我在哪里可以放入jquery代码?哪一个对我有用?

<!DOCTYPE html>
<html>

    <head>

        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="jquery.mobile-1.4.5.css">
        <script src="jquery-1.12.0.min.js"></script>
        <script src="jquery.mobile-1.4.5.min.js"></script>


    </head>


    <body>



        <div data-role="page" id="home"  >
            <div id="header">
                <h1 align="center";><font color="white">Member Login</font></h1>

            </div>
            <form>
                <input type="text" placeholder="Username">

                <input type="text" placeholder="Health Card Number">
                <input id="rememberme" type="checkbox">
                <label for="rememberme">Remember</label>
                <input type="submit" value="Login Now">
            </form>
</div>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

试一试:

<script>
        $("document").ready(function(){
           $("#home").css("background-image","url('http://cache1.asset-cache.net/gc/519249945-hexagon-abstract-background-gettyimages.jpg?v=1&c=IWSAsset&k=2&d=LBXRX%2BPPwv%2BPvsKWANsuTH1c3dDbAxUoJxxrmsO0Fpr0Z7%2BFa7zjX%2F4eaCS3h%2B2h')");
        });
    </script>

在此处查看演示:plunker