javascript innerHTML adding instead of replacing
<div id=”whatever”>hello one</div> <script> document.getElementById(“whatever”).innerHTML += ” hello two”; </script>
<div id=”whatever”>hello one</div> <script> document.getElementById(“whatever”).innerHTML += ” hello two”; </script>
How about: function deleteRow(rowid) { var row = document.getElementById(rowid); row.parentNode.removeChild(row); } And, if that fails, this should really work: function deleteRow(rowid) { var row = document.getElementById(rowid); var table = row.parentNode; while ( table && table.tagName != ‘TABLE’ ) table = table.parentNode; if ( !table ) return; table.deleteRow(row.rowIndex); }
DOM mutation events (I believe not supported in all browsers) .. see http://en.wikipedia.org/wiki/DOM_events#Common.2FW3C_events
TL;DR: Parsing starts instantaneously after receiving the document. Parsing and painting For a more detailed explanation, we need to dive into the way rendering engines work. Rendering engines parse the HTML document and create two trees: the content tree and the render tree. A content tree contains all DOM nodes. The render tree contains all … Read more
The answer to this question is to use a ref as described on Refs to Components. The underlying problem is that the DOM node (and its parent DOM node) is needed to properly position the element, but it’s not available until after the first render. From the article linked above: Performing DOM measurements almost always … Read more
window.screenX/Y are not supported on IE. But for other browsers, a close approximation of position is: var top = $(“#myelement”).offset().top + window.screenY; var left = $(“#myelement”).offset().left + window.screenX; Exact position depends on what toolbars are visible. You can use the outer/innerWidth and outer/innerHeight properties of the window object to approximate a little closer. IE doesn’t … Read more
@felix-king is correct, this is a firefox devtools errors. It usually happens when you inspect an object and you open a base prototype tree node lower than the type of the instance you are inspecting. So this explains the “this” error problem that @jfriend00 refers to in the comment, even though you don’t reference “this” … Read more
This cannot be done. When a script is executed, function definitions are added to the global window object. There may be debugging symbols attached to the function that indicate where the function came from, but this information is not available to scripts. About the only way you could achieve something like this would be to … Read more
As @FelixKling pointed out in the comments: inner.offsetTop is what to use for this. scrollTop returns the amount you scrolled in that particular container. So because inner doesn’t have a scrollbar, it never scrolls, and therefore scrollTop is 0. But offsetTop, on the other hand, returns the distance of the current element relative to the … Read more