Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用jquery或纯javascript选择vml元素?_Javascript_Jquery_Html_Dom_Vml - Fatal编程技术网

如何使用jquery或纯javascript选择vml元素?

如何使用jquery或纯javascript选择vml元素?,javascript,jquery,html,dom,vml,Javascript,Jquery,Html,Dom,Vml,我想在不使用“id”或“class”的情况下使用jquery选择VML元素,但我的尝试无效 <v:oval id="vmlElement" style='width:100pt;height:75pt' fillcolor="red"> </v:oval> $(document).ready(function(){ //don't work var oItem = $("v");//from here I should look for the n-t

我想在不使用“id”或“class”的情况下使用jquery选择VML元素,但我的尝试无效

<v:oval id="vmlElement" style='width:100pt;height:75pt' fillcolor="red"> </v:oval>


$(document).ready(function(){
    //don't work
    var oItem = $("v");//from here I should look for the n-th 'v' element, but for this example it is not necessary
    $(oItem).attr("fillcolor", "green")
    //alert($(oItem).attr("fillcolor"));

    //This worked, but I can't use select to id, or class
    $('#vmlElement').eq(0).attr("fillcolor", "green");
});
我知道VML太旧了,最好使用SVG。但是,由于我们需要与旧浏览器兼容,我们必须使用VML。对于所有普通的浏览器,我们都使用SVG,一切运行起来都很有魅力


非常感谢。

您可以尝试使用完整的标记名v:oval

使用jQuery:

$("v\\:oval")
使用JavaScript:

document.getElementsByTagName("v:oval")
请注意,您需要转义: