I am doing this with jQuery :
@xmlOut = $('<rules />')
@xmlOut.attr('xsi:schemaLocation','test')
I get this :
<rules xsi:schemalocation='test'></rules>
The "L" is not uppercase anymore...
I am doing this with jQuery :
@xmlOut = $('<rules />')
@xmlOut.attr('xsi:schemaLocation','test')
I get this :
<rules xsi:schemalocation='test'></rules>
The "L" is not uppercase anymore...
Share Improve this question edited Nov 20, 2012 at 10:19 Sebastien asked Nov 20, 2012 at 10:10 SebastienSebastien 6,66014 gold badges59 silver badges105 bronze badges3 Answers
Reset to default 10There is a ticket http://bugs.jquery.com/ticket/11166
Alternatively, you can add attribute hook (with lowercase name) to jQuery in order to use desired setter method. For example:
$.attrHooks['viewbox'] = {
set: function(elem, value, name) {
elem.setAttributeNS(null, 'viewBox', value + '');
return value;
}
};
Then you can set the attribute case sensitive with .attr():
$('svg').attr('viewBox', '0 0 100 100');
Try using plain Javascript's setAttribute
which is not case sensitive.
@xmlOut.get(0).setAttribute('xsi:schemLocation', 'test');
Kevin's answer is incorrect, .setAttribute() will change the attribute name to lowercase.
Instead, use element.setAttributeNS() with an empty string for the first parameter.
@xmlOut.get(0).setAttributeNS('', 'xsi:schemaLocation','test')
https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttributeNS