dom

How can i get the position number of an element?

会有一股神秘感。 提交于 2020-01-15 08:05:10
问题 Is there any plugin in firefox or function in firebug or something else, that lets me se the position number of a specific element? If i for example want to know the what position a specific TD element has compared to all the TD's in the document. EXAMPLE: <html> <head> <body> <table> <tr> <td></td> (0) <td></td> (1) <td></td> (2) <td></td> (3) <td></td> (And so on...) <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <------ WHAT IS THE POSITION NUMBER OF THIS

How to get the size of a HTA window?

♀尐吖头ヾ 提交于 2020-01-15 07:34:53
问题 You can SET the size of a HTA window but I can't find a way to GET its size. All I can think of is reading document.body.offsetWidth and .offsetHeight , but those give you the viewport size not the actual window size. Is it possible to know that? 回答1: It seems there are no properties or methods to get that information. The now beta-released IE9 has the new properties outterWidth and outterHeight , but that is not an option for now. So I devised a workaround for this: function

Can't find element inside template with querySelector - Polymer

╄→гoц情女王★ 提交于 2020-01-15 07:33:48
问题 When I try to querySelector an element inside a template tag from external file I get undefined, after a little bit of searching the only solution I found was the 'shadowRoot' but when I tried to use it I got 'shadowRoot is not defined'. 回答1: The following code works fine for me (jsbin): <template is="auto-binding" id="tmpl"> <h1>Hello from {{foo}}</h1> </template> <script> document.addEventListener('polymer-ready', function() { var tmpl = document.querySelector('#tmpl'); tmpl.foo = 'my thing

Is this a double document ready?

六眼飞鱼酱① 提交于 2020-01-15 05:06:29
问题 I'm working with a script and have found the following, which I really can't find any info of what it means (function($) { $(document).ready(function(e) { ... bla bla bla ... }); }) (jQuery); Is (function($){}) (jQuery); the same as $(function () {}); ? and if so, why would somebody define twice document.ready ? 回答1: No, it's not the same. It's an anonymous function which is being passed the jQuery object, to insure that it is available as the local variable $ within the scope of the function

Chrome doesn't fire click event for SVG element (Firefox does)

别来无恙 提交于 2020-01-15 04:35:48
问题 I observe inconsistency/bug in handling click event among various browsers (Chrome, Edge, Firefox). In my JavaScript library that uses SVG I create clickable and draggable rectangles. When I run my snippet in Chrome browser the click event is not firing if 2 or more elements are present on canvas. To check this you need to create at least 2 rectangles on canvas. You can drag them with mouse (Rectangles initial position is the same). Normally rectangle's border become brown if click event was

Refactoring a function that uses window.open to use the DOM rather than write()

余生长醉 提交于 2020-01-15 03:15:13
问题 I have an application that uses window.open() to generate dynamic popups. Unfortunately, I've had trouble creating the content of the new windows using the standard DOM functions ( createElement , appendChild ), and I've gone to using document.write() to generate the page. Concretely, how can I go from this: function writePopup() { var popup = window.open("", "popup", "height=400px, width=400px"); var doc = popup.document; doc.write("<html>"); doc.write("<head>"); doc.write("<title>Written

Refactoring a function that uses window.open to use the DOM rather than write()

久未见 提交于 2020-01-15 03:15:08
问题 I have an application that uses window.open() to generate dynamic popups. Unfortunately, I've had trouble creating the content of the new windows using the standard DOM functions ( createElement , appendChild ), and I've gone to using document.write() to generate the page. Concretely, how can I go from this: function writePopup() { var popup = window.open("", "popup", "height=400px, width=400px"); var doc = popup.document; doc.write("<html>"); doc.write("<head>"); doc.write("<title>Written

Effect of adding excessiv ID's on html / js rendering performance

纵然是瞬间 提交于 2020-01-15 01:48:46
问题 A project I'm currently working currently has about 10 ULs, each which will have anywhere from 10-50 elements in them. Its been proposed that each of those elements have a unique ID specified to it that we will use to update content with via Javascript. This seems like a large number of IDs to add to a page, but each field will have a real and meaningful name. If this is useful to us, are will adding IDs to this many already existing elements have any effects on performance while initially

DOM文档对象模型

青春壹個敷衍的年華 提交于 2020-01-15 01:08:48
JavaScript HTML DOM 通过 HTML DOM,可访问 JavaScript HTML 文档的所有元素。 HTML DOM (文档对象模型) 当网页被加载时,浏览器会创建页面的文档对象模型(Document Object Model)。 HTML DOM 模型被构造为对象的树: 通过可编程的对象模型,JavaScript 获得了足够的能力来创建动态的 HTML。 JavaScript 能够改变页面中的所有 HTML 元素 JavaScript 能够改变页面中的所有 HTML 属性 JavaScript 能够改变页面中的所有 CSS 样式 JavaScript 能够对页面中的所有事件做出反应 查找 HTML 元素 通常,通过 JavaScript,您需要操作 HTML 元素。 为了做到这件事情,您必须首先找到该元素。有三种方法来做这件事: 通过 id 找到 HTML 元素 通过标签名找到 HTML 元素 通过类名找到 HTML 元素 通过 id 查找 HTML 元素 在 DOM 中查找 HTML 元素的最简单的方法,是通过使用元素的 id。 本例查找 id=“intro” 元素: 实例 var x = document . getElementById ( "intro" ) ; 如果找到该元素,则该方法将以对象(在 x 中)的形式返回该元素。 如果未找到该元素,则

JavaScript 文档对象模型(DOM)

天大地大妈咪最大 提交于 2020-01-14 20:32:40
文章目录 一、什么是DOM 二、获取文档中的指定元素 1、通过元素的id属性获取元素 例子:在页面指定位置显示当前日期 2、通过元素的name属性获取元素 例子:实现电影图片的轮转效果 三、DOM对象节点属性 四、节点的操作 1、创建节点 例子:补全古诗 2、插入节点 例子:向页面中插入文本 3、复制节点 例子:复制下拉菜单 4、删除节点 例子:删除最后一个文本 5、替换节点 例子:替换标记和文本 未完待续 五、与DHTML相对应的DOM 1、innerHTML和innerText属性 例子:显示当前事件和分时问候语 2、outerHTML和outerText属性 一、什么是DOM 什么是 DOM ?逐步分解各个单词, D-O-M ,D就是 Document(文档) ;O就是 Object(对象) ;M就是 Model(模型) 。合起来就是 文档对象模型 ……很粗暴。那么文档对象模型是什么呢? 文档对象模型就是一种与浏览器、平台、语言无关的接口,通过 DOM 可以访问页面中的其他标准组件。它给开发者定义了一个标准的方法,使他们访问页面中的数据、脚本还有表现层对象。也就是说脚本可以直接操控页面中的标签。 DOM采用的是树形结构,学过数据结构的可能都不陌生。比如下面一段HTML代码: < html lang = "en" > < head > < meta charset = "UTF