您的位置:首页 > Web前端 > JQuery

Jquery load()方法 实现公用头部 尾部

2015-08-12 20:59 671 查看
//这是header.html里的代码,想作为头部引进来

<div id="loginBox">
    <span></span>
    <div>
        <div>
            <img src="common/images/login.jpg" alt="login"/>
        </div>
        <div>

        </div>
        <div>
            <label for="">
                <span>姓名:</span>
                <input id="username" type="text" placeholder="input your name"/>
            </label>
        </div>
        <div>
            <label for="">
                <span>密码:</span>
                <input id="password" type="password" placeholder="input your password"/>
            </label>
        </div>
        <div>
            <b>
                <button type="submit" id="loginsub" class="btn btn-success" >登陆</button>
                <button type="reset" id="loginset" class="btn btn-danger">重置</button>
            </b>
        </div>
    </div>
</div>


在header.js里边这样写

$("#header").load('common/html/header.html', function (data, status, xhr) {})


在在想要引用的文件中找到想引用的部分即可

<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../common/css/header.css"/>
    <link rel="stylesheet" href="../common/css/footer.css"/>
    <link rel="stylesheet" href="../tool/bootstrap/dist/css/bootstrap.css"/>
    <link rel="stylesheet" href="css/management.css"/>
    <title>Hisense</title>
</head>
<body>
<div id="header"></div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: