gpt4 book ai didi

javascript - 如何在控制台中调试 jQuery?

转载 作者:行者123 更新时间:2023-11-30 14:07:33 30 4
gpt4 key购买 nike

我在这里查看 jQuery 进度条示例: https://jqueryui.com/progressbar/

代码如下:

<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Progressbar - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("#progressbar").progressbar({
value: 76
});
});
</script>
</head>
<body>
<h2>jQuery progress bar</h2>
<div id="progressbar" class="bar"></div>
</body>
</html>

我的问题是如何将 console.log 放在某处以查看等于 76 的变量 value 的值?我试过 console.log(value), console.log($("#progressbar").value), console.log($("#progressbar").progressbar.value),这些都不起作用。

最佳答案

你的 progress bar 将一个对象作为 param 所以你可以这样做你的 console.log:选项选项名称

获取值的示例:progressbar("option", "value")

progressbar("value")

我建议阅读文档以获取更多详细信息:

Progress bar

$(document).ready(function() {

$("#progressbar").progressbar({
value: 76
});

//Get the progress bar value

const value = $("#progressbar").progressbar("option", "value");

console.log(value)
});
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Progressbar - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
</script>
</head>

<body>
<h2>jQuery progress bar</h2>
<div id="progressbar" class="bar"></div>
</body>

</html>

关于javascript - 如何在控制台中调试 jQuery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55107084/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com