Javascript DOM How to - Create element with namespace








Question

We would like to know how to create element with namespace.

Answer


<!--  w  w  w . j  a  v a2  s  .  c  o  m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){
    var a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
    console.log(a instanceof SVGElement)
}
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: