1

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.

asked Mar 11, 2019 at 17:14
1

1 Answer 1

2

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:

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>

answered Mar 11, 2019 at 17:17
Sign up to request clarification or add additional context in comments.

1 Comment

You are just logging the object you created. Not the actual value of the progress bar

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.