dom
INVALID_STATE_ERR: DOM Exception 11 (WebKit)
Usually this error occurs with the XMLHttpRequest when you call the open method with async = true, or you leave the async parameter undefined so it defaults to asynchronous, and then you access the status or responseText properties. Those properties are only available after you do a synchronous call, or on the readyState becoming ready …
Watching for DOM changes, the elegant way
Would this work? http://darcyclarke.me/development/detect-attribute-changes-with-jquery/ $.fn.watch = function(props, callback, timeout){ if(!timeout) timeout = 10; return this.each(function(){ var el = $(this), func = function(){ __check.call(this, el) }, data = { props: props.split(“,”), func: callback, vals: [] }; $.each(data.props, function(i) { data.vals[i] = el.css(data.props[i]); }); el.data(data); if (typeof (this.onpropertychange) == “object”){ el.bind(“propertychange”, callback); } else if ($.browser.mozilla){ el.bind(“DOMAttrModified”, …
React – get React component from a child DOM element?
No. A central concept in React is that you don’t actually have a control in the DOM. Instead, your control is that factory function. What’s in the DOM is the current render of the control. If you actually need this, you can keep an object as a global variable, whose keys are the string representations …
Does the order of elements in a jQuery-wrapped set always match the order in which the elements appear in the markup?
Just been looking at this myself. jQuery does return things in document order as per the following article: http://docs.jquery.com/Release:jQuery_1.3.2 So, if you select some ids as such: $(“#id1, #id2, #id3”) Then they will be returned in the order they appear in the DOM, not necessarily in the order they are given. Its certainly worth being …
jQuery .each() returns DOM element and not a jQuery object
The documention is not wrong but you may misunderstand what a jQuery object is. The jQuery object is returned by the $() function. So $(“span[id$=’_TotalItemCost’]”) is one jQuery object which contains every span element selected. Using .each() will iterate over the elements contained in the jQuery object. This is why this is a DOM node …
White spaces are required between publicId and systemId
The error message is actually correct if not obvious. It says that your DOCTYPE must have a SYSTEM identifier. I assume yours only has a public identifier. You’ll get the error with (for instance): <!DOCTYPE persistence PUBLIC “http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd”> You won’t with: <!DOCTYPE persistence PUBLIC “http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd” “”> Notice “” at the end in the second one …
async=true for css link tag
2021 edit: Original link moved – async CSS without JavaScript https://codepen.io/tigt/post/async-css-without-javascript “It seems this trick causes Chrome & Firefox to start the body earlier, and they simply don’t block for body stylesheets.” <head> <!–[if IE]> <link rel=”stylesheet” href=”style.css”> <![endif]–> </head> <body> <!–[if !IE]> –> <link rel=”stylesheet” href=”style.css” lazyload> <!– <![endif]–> </body> The article also contains …
Unloading/Removing content from an iFrame
The other solutions use innerHTML, which won’t always work in XHTML. They also only clear document.body (anything in the <head> is still present). Here is a solution that uses the DOM: var frame = document.getElementById(“myFrame”), frameDoc = frame.contentDocument || frame.contentWindow.document; frameDoc.removeChild(frameDoc.documentElement); This solution uses innerHTML: var frame = document.getElementById(“myFrame”), frameDoc = frame.contentDocument || frame.contentWindow.document; frameDoc.documentElement.innerHTML …
jQuery – Get element from array as jQuery element?
Use the eq() method: $(“.myClass”).eq(0) This returns a jQuery object, whereas .get() returns a DOM element. .eq() lets you specify the index, but if you just want the first you can use .first(), or if you just want the last you can use (surprise!) .last(). “I get an array of elements.” No you don’t, you …