最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery and HTML5 elements - Stack Overflow

programmeradmin0浏览0评论

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: /

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/z5t3g/

Share Improve this question edited Feb 1, 2015 at 16:30 Deduplicator 45.8k7 gold badges72 silver badges123 bronze badges asked Feb 24, 2011 at 20:56 pimvdbpimvdb 155k80 gold badges311 silver badges356 bronze badges 2
  • 1 you have to reference html elements like $('progress'), i think you can then select based on the value as well. – jonezy Commented Feb 24, 2011 at 20:57
  • Appreantly, using HTML for the element and then accessing it with $('#progress') doesn't work either: jsfiddle/z5t3g. – pimvdb Commented Feb 24, 2011 at 21:02
Add a ment  | 

4 Answers 4

Reset to default 2

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

Use a jquery selector for it

$("progress").val();

try this:

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

You'll want to do this

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

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

发布评论

评论列表(0)

  1. 暂无评论