[英]jQuery and HTML5 elements
I was wondering whether or not jQuery supports HTML5 elements. 我想知道jQuery是否支持HTML5元素。
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? jQuery是否会在未来支持HTML5元素,或者我是否以这种方式做错了什么?
EDIT: It does not seem to be the selector: http://jsfiddle.net/z5t3g/ 编辑:它似乎不是选择器: http : //jsfiddle.net/z5t3g/
If you have your <progress />
element in the DOM: 如果您在DOM中有
<progress />
元素:
<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. 您可以使用jQuery选择它,但似乎(从版本1.5开始)它不知道使用
.val()
方法返回value
属性。 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. 您无法使用jQuery选择整个标记。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.