I\'m trying to manipulate the svg \'viewBox\' attribute which looks something like this:
You could use jQuery hooks:
['preserveAspectRatio', 'viewBox'].forEach(function(k) {
$.attrHooks[k.toLowerCase()] = {
set: function(el, value) {
el.setAttribute(k, value);
return true;
},
get: function(el) {
return el.getAttribute(k);
},
};
});
Now jQuery will will use your setter/getters to manipulate those attributes.
Note that el.attr('viewBox', null) would have failed; your hook setter won't be called. Instead you should use el.removeAttr('viewBox').