Getting ‘xlink:href’ attribute of the SVG element dynamically using JS in HTML DOM
The correct usage is getAttributeNS(‘http://www.w3.org/1999/xlink’, ‘href’);
The correct usage is getAttributeNS(‘http://www.w3.org/1999/xlink’, ‘href’);
They are different things for different purposes, so comparing performance doesn’t make sense. Virtual DOM Virtual DOM is about avoiding unnecessary changes to the DOM, which are expensive performance-wise, because changes to the DOM usually cause re-rendering of the page. Virtual DOM also allows to collect several changes to be applied at once, so not … Read more
At the time window is loaded the body isn’t still loaded therefore you should correct your code in the following manner: <script type=”text/javascript”> window.onload = function(){ window.document.body.onload = doThis; // note removed parentheses }; function doThis() { if (document.getElementById(“myParagraph”)) { alert(“It worked!”); } else { alert(“It failed!”); } } </script> Tested to work in FF/IE/Chrome, … Read more
For those looking for a practical solution, see: How to find event listeners on a DOM node when debugging or from the JavaScript code? EventListenerList was in some old draft of DOM 3 Events and was long removed from the spec. As far as I know, at least Gecko still doesn’t have anything like this … Read more
not() is a function in XPath (as opposed to an operator), so //a[not(contains(@id, ‘xx’))]
First of all you can only accomplish this if your frame and the page displaying it is within the same domain (Due to cross-domain rules) secondly you can manipulate dom and window objects of the frame directly through JS: frames[0].window.foo = function(){ console.log (“Look at me, executed inside an iframe!”, window); } to get your … Read more
Although Chrome does not dispatch DOMAttrModified events, the more lightweighted mutation observers are supported since 2011 and these work for attribute changes, too. Here is an example for the document body: var element = document.body, bubbles = false; var observer = new WebKitMutationObserver(function (mutations) { mutations.forEach(attrModified); }); observer.observe(element, { attributes: true, subtree: bubbles }); function … Read more
Sass is just a CSS generator. It doesn’t really interact with your HTML, so you can’t use HTML attributes as Sass variables. However, CSS can select based on attributes. So it will be more long-winded than you might like, but you can do something like ul[data-count=”3″]:after content: “There were three items in that list!” And … Read more