Reputation: 344
I am trying to delete the string attribute here, but I guess I don't have reference to the child node. How should this work?
<!DOCTYPE HTML>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<script type="text/javascript">
var attrs = document.getElementById('test-1');
attrs.removeAttribute('string');
</script>
<mask>
<mpath>
<font-face-format string="" id="test-1"></font-face-format>
</mpath>
</mask>
</svg>
Upvotes: 0
Views: 300
Reputation: 11618
You are trying to reference it when it still doesn't exist.
try moving your script block to the end of the document like
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<mask>
<mpath>
<font-face-format string="" id="test-1"></font-face-format>
</mpath>
</mask>
<script type="text/ecmascript">
var attrs = document.getElementById('test-1');
attrs.removeAttribute('string');
</script>
</svg>
Upvotes: 2
Reputation: 18578
make use of window.onload
so that the code will executed once the element is created. try this
<script type="text/javascript">
window.onload = function(){
var attrs = document.getElementById('test-1');
attrs.removeAttribute('string');
};
</script>
Upvotes: 2