开发者

$(document).height() no workey

Why are the 3rd and 4th inputs not being populated?

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style>
label {
    display:block;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1");
</script>
</head>

<body>
<form>
    <label for="WindowHeight">Window Height:</label>
    <input name="WindowHeight">
    <label for="WindowWidth">Window Width:</label>
    <input name="WindowWidth">
    <label for="DocumentHeight">Document Height:</label>
    <input name="DocumentHeight">
    <label for="DocumentWidth">Document Width:</label>
    <input name="DocumentWidth">
</form>
<script>
function Populate() {
    $('input[name=WindowHeight]').val($(window).height());
    $('input[name=WindowWidth]').val($(window).wi开发者_Go百科dth());
    $('input[name=DocumentHeight').val($(document).height());
    $('input[name=DocumentWidth').val($(document).width());
}

$(window).resize(function() {
    Populate();
});
Populate();
</script>
</body>
</html>


You're missing two ]s:

function Populate() {
    $('input[name=WindowHeight]').val($(window).height());
    $('input[name=WindowWidth]').val($(window).width());
    $('input[name=DocumentHeight]').val($(document).height());
    //                        --^
    $('input[name=DocumentWidth]').val($(document).width());
    //                       --^
}


You are missing closing brackets here:

$('input[name=DocumentHeight').val($(document).height());
$('input[name=DocumentWidth').val($(document).width());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜