$ (document) .height () без проблем - PullRequest
2 голосов
/ 12 января 2011

Почему 3-й и 4-й входы не заполняются?

<!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).width());
    $('input[name=DocumentHeight').val($(document).height());
    $('input[name=DocumentWidth').val($(document).width());
}

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

Ответы [ 2 ]

6 голосов
/ 12 января 2011

Вам не хватает двух ] с:

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());
    //                       --^
}
3 голосов
/ 12 января 2011

Здесь отсутствуют закрывающие скобки:

$('input[name=DocumentHeight').val($(document).height());
$('input[name=DocumentWidth').val($(document).width());
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...