Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery and HTML5 elements

I was wondering whether or not jQuery supports HTML5 elements.

For example, I tried this code but it fails with a rather weird error:

$('<progress value="2">').val();

It says:

TypeError: Object 1 has no method 'replace'

Is jQuery to support HTML5 elements in the future, or am I doing something wrong this way?

EDIT: It does not seem to be the selector: http://jsfiddle.net/z5t3g/

like image 339
pimvdb Avatar asked Oct 11 '22 15:10

pimvdb


2 Answers

If you have your <progress /> element in the DOM:

<progress value="2" />

You can select it using jQuery, but it seems that (as of version 1.5) it doesn't know to return the value attribute using the .val() method. You need to check the attribute by name:

$('progress').attr('value');
like image 128
jevakallio Avatar answered Nov 15 '22 06:11

jevakallio


Use a jquery selector for it

$("progress").val();
like image 28
Jimmy Avatar answered Nov 15 '22 07:11

Jimmy