Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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
Javascript 为什么getAttributeNS返回null?_Javascript_Svg - Fatal编程技术网

Javascript 为什么getAttributeNS返回null?

Javascript 为什么getAttributeNS返回null?,javascript,svg,Javascript,Svg,var svg=document.getElementById('test'), use=svg.lastElementChild; 警报(使用.getAttributeNS(null,'x')); // "200" 警报(使用.getAttributeNS('s)http://www.w3.org/1999/xlink“,”href'); //“#形状” 警报(使用.getAttributeNS('s)http://foo.io/bar","foo"),; //空-为什么? 查看MDN页面,h

var svg=document.getElementById('test'),
use=svg.lastElementChild;
警报(使用.getAttributeNS(null,'x'));
// "200"
警报(使用.getAttributeNS('s)http://www.w3.org/1999/xlink“,”href');
//“#形状”
警报(使用.getAttributeNS('s)http://foo.io/bar","foo"),;
//空-为什么?

查看MDN页面,html5文档中似乎不支持名称空间-


看起来您必须使用
use.getAttribute('test:foo')

谢谢。在示例部分,我完全忽略了这一点。我想我被甩了,因为它为特定的名称空间工作(即
http://www.w3.org/1999/xlink