dom

What are HTML DOM #text elements?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-24 02:28:04
问题 I'm learning knockout.js and trying to use an afterRender callback to apply behaviour to elements. I don't understand what these #text elements are that show up in my console.log() . So UI looks like this: Knockout binding like this: <div id='categoriesTree' style="color:black"> <table class='categoriesEditor'> <tbody data-bind="template: { name: 'itemTmpl', foreach:children, afterRender: myPostProcessingLogic2 }"></tbody> </table> </div> Template: <script id="itemTmpl" type="text/html"> <tr>

“Permission denied to access property 'href' from a non-chrome context” in JavaScript and OpenLayers

断了今生、忘了曾经 提交于 2020-01-24 00:43:29
问题 This is really two questions one leading into the other. Firstly what does 'Permission denied to access property 'href' from a non-chrome context' actually mean? Secondly I am using overlays in OpenLayers and wish to change the opacity of said layers, this is where this error is being thrown the code of which is here... <input id='opacity' value="1.0" onChange="changeOpacity()"> Of which changeOpacity() is the following function... function changeOpacity() { var newOpacity = parseFloat

前端面试(一)

血红的双手。 提交于 2020-01-23 22:56:59
2020年1月4日面试问题梳理: 1、Vue相对于原生JS的优势在哪里 认知 现代JS框架存在的根本原因是保持UI与状态同步 核心思想 数据驱动 DOM 核心功能 数据双向绑定 组件(Component) 核心概念 异步更新队列 el: el用于指定一个页面中已存在的DOM元素来挂载Vue实例。 beforeDestroy生命周期:实例销毁之前调用。主要解绑一些使用addEventListener 监听事件等 时间定时器 const timer = setInterval ( function ( ) { that . date = new Date ( ) ; } , 1000 ) clearInterval ( timer ) filter: Vue的过滤器 v-text&v-html v-html: 如果将用户产生的内容使用 v-html 输出后,有可能导师XSS攻击,所以要在服务端对用户提交的内容进行处理,一般可将尖括号“<>”转义 v-pre: < span v - pre > { { 这里的内容不会被编译 } } < / span > vue.js只支持单个表达式,不支持语句和流控制。 v-bind & v-on :语法糖分别是“:”&"@" 语法糖:语法糖是指在不影响功能的情况下,添加某种方法实现同样的效果,从而方便程序开发。 Vue 在检测到数组变化时

何时选用CSS何时选用DOM?

限于喜欢 提交于 2020-01-23 18:47:47
用DOM方法设置样式十分灵活,可以动态创建标记,设置内嵌.style样式(驼峰命名)或者说直接改变一个class属性。而CSS样式丰富多彩,引入许多选择器first-child, last-child,nth-child(),nth-of-type()等等,也有伪类选择器属性 描述a:link a:visited a:hover a:active等等。那么什么时候用CSS设置样式,什么时候用DOM修改样式呢?在这个问题上没有放之四海皆准的答案。 毫无疑问,CSS用来设置网页样式,大多时候我们都用CSS设置去创建重要样式,而用DOM去对文档做一些增强。 那么什么时候去选用DOM方法修改而不是CSS呢?下面我们将从一些适应范围来分析这个问题: 1.根据元素在节点树中的位置来设置样式 我们来看这样一组标记: < h1 > What is the Document Subject Model? </ h1 > < p > The < abbr title = " World Wide Web Consortium " > W3C </ abbr > defines the < abbr title = " Document Object Model " > DOM </ abbr > as: </ p > < p > A platfrom- and language-neutral

How to get value from <li> tag

不问归期 提交于 2020-01-23 13:27:11
问题 I'm a beginner in React.js and need some help. I want to get the value or data from a <li> -tag when you click on it. How can I do that? ... clickOnMe : function () { this.setState({myData : event.target.value}); } render : function (){ return ( <div> <ul> <li value="Point" onClick={this.clickOnMe}>Point</li> </ul> </div> ); } ... 回答1: You're getting undefined because target.value is only used for form elements such as input . You can pass the function a unique identifier, which you then can

jQuery continue loop execution after ajax success

扶醉桌前 提交于 2020-01-23 09:26:26
问题 I have a jQuery ajax call in a loop. However I do not want those ajax calls to be made simultaneously, I need the first ajax call to finish before going on to the next. for (var i = 0; i < options.length; i++) { jQuery.ajax({ url: "ajax_file.php", data: //some data based on DOM tree success: function(data){ //some DOM manipulation } }); } I want the loop to continue executing only after the DOM manipulation in SUCCESS was executed (because the ajax call depends on the DOM tree). In theory I

How should boolean attributes be written? [duplicate]

江枫思渺然 提交于 2020-01-23 08:00:30
问题 This question already has answers here : What values can appear in the “selected” attribute of the “option” tag? (8 answers) Closed 5 years ago . I've been reading some articles about HTML, XHTML, etc. In most of them (i.e. My preferred syntax style) say that boolean attributes should be written without any value, like this: <input type="text" required> They even say that it is wrong to use this attributes like this: <input type="text" required="required"> Some of this articles link W3 which

Pass React Ref from parent to child in order to get DOM element

有些话、适合烂在心里 提交于 2020-01-23 07:20:51
问题 I have a parent and a child component. I need to access the parent's HTMLelement in the child component. I have a working but unclean solution involving this.setState({ domNode: ReactDOM.findDOMNode(this) }); in the parent's componentDidMount which is just wrong on many levels. How can i do this using createRef() in the parent to pass its ref as a prop to the child and then how do i get the DOM node with type HTMLElement from the ref? 回答1: The best solution that doesn't involve any hack would

Dom对象与jQuery对象区别与相互转换

不想你离开。 提交于 2020-01-23 02:42:35
Dom对象与jQuery对象区别与相互转换 1、概念 1.1、Dom对象 Dom对象,即文档对象模型,通过Dom,我们可以访问所有HTML的元素,包括他们的文本和属性。可以对其中的内容进行修改和删除,还可以创建新元素。Dom对象无法无法使用jQuery对象中的方法。 实例: var Obj = document.getElementById(“id”); 1.2、jQuery对象 jQuery对象实际是JavaScript的一个数组,是通过jQuery包装Dom对象后产生的对象,可以使用jQuery对象中的方法,但并不能使用Dom中的方法。 实例: var $obj = $("#id"); 2、相互转换 2.1、jQuery对象转成Dom对象 2.2、Dom对象转换成jQuery对象 来源: CSDN 作者: Axtone 链接: https://blog.csdn.net/qq_39859899/article/details/103879389

Vue响应式原理

纵然是瞬间 提交于 2020-01-23 02:36:52
原文链接:http://www.cnblogs.com/xiaohuochai/p/7371743.html 前面的话   Vue最显著的特性之一便是不太引人注意的响应式系统(reactivity system)。模型层(model)只是普通JS对象,修改它则更新视图(view)。这会让状态管理变得非常简单且直观,不过理解它的工作原理以避免一些常见的问题也是很重要的本文将详细介绍Vue响应式系统的底层细节 追踪变化   把一个普通JS对象传给Vue实例的 data 选项,Vue将遍历此对象所有的属性,并使用Object.defineProperty把这些属性全部转为getter/setter。Object.defineProperty是仅ES5支持,且无法shim的特性,这也就是为什么Vue不支持IE8浏览器的原因   用户看不到getter/setter,但是在内部它们让Vue追踪依赖,在属性被访问和修改时通知变化   每个组件实例都有相应的 watcher 实例对象,它会在组件渲染的过程中把属性记录为依赖,之后当依赖项的 setter 被调用时,会通知 watcher 重新计算,从而致使它关联的组件得以更新 变化检测   受现代JS的限制(以及废弃 Object.observe ),Vue 不能检测到对象属性的添加或删除 。由于Vue会在初始化实例时对属性执行 getter