如何使用jquery或纯javascript选择vml元素?
我想在不使用“id”或“class”的情况下使用jquery选择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
<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")
请注意,您需要转义: