简体   繁体   中英

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/

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');

试试这个:

$('#progress').val();

使用jquery选择器

$("progress").val();

You'll want to do this

$('progress[value=="2"]).val();

You can't select using the entire tag with jQuery.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM