Wern Ancheta
Wern Ancheta

Reputation: 23297

How to get current value of progress bar with jQuery?

I'm trying out some new HTML5 form features in the latest version of Opera.

<progress value="1" max="10"></progress>

What I want to do is to get the current value of the progress bar using jQuery.

I tried...

$(function(){
    alert($('progress').val());

});

...but it didn't do anything.

How can I get the current value using jQuery?

Upvotes: 2

Views: 4366

Answers (1)

alex
alex

Reputation: 490153

Using jQuery's val() threw an error for me, so I used the native value property.

var value = $('progress:first').prop('value'); 

jsFiddle.

If using < 1.6, then use [0].value to access the native value property.

Upvotes: 3

Related Questions