I'm looking at the jQuery progress bar example from here: https://jqueryui.com/progressbar/
Here is the code:
<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>
My question is how can I put console.log somewhere to see the value of variable value which equals to 76? I've tried console.log(value), console.log($("#progressbar").value), console.log($("#progressbar").progressbar.value), none of these works.
-
1From the API: api.jqueryui.com/progressbar/#method-valueepascarello– epascarello2019年03月11日 17:16:47 +00:00Commented Mar 11, 2019 at 17:16
1 Answer 1
your progress bar is taking an object as param so you can do your console.log that way: the option and the option name
For Example to get the value : progressbar("option", "value")
OR
progressbar("value")
I recommend reading the documentation for more details:
$(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>