dom

DOM&BOM-w3school(2020.2.11)【js HTML DOM】

丶灬走出姿态 提交于 2020-02-12 04:37:19
一、js HTML DOM (一)DOM简介 1.通过 HTML DOM,JavaScript 能够访问和改变 HTML 文档的所有元素。 当网页被加载时,浏览器会创建页面的文档对象模型(Document Object Model)。 HTML DOM 模型被结构化为对象树: HTML DOM 是: • HTML 的标准对象模型 • HTML 的标准编程接口 • W3C 标准 W3C DOM 标准被分为 3 个不同的部分: ·Core DOM - 所有文档类型的标准模型 ·XML DOM - XML 文档的标准模型 ·HTML DOM - HTML 文档的标准模型 总之:HTML DOM 是关于如何获取、更改、添加或删除 HTML 元素的标准。 2. 创建动态 HTML DOM一般用法 • 改变 HTML 元素的内容 • 改变 HTML 元素的样式(CSS) • 对 HTML DOM 事件作出反应 • 添加和删除 HTML 元素 3. javascript 有三部分构成,ECMAScript,DOM和BOM (二)DOM方法 1.在 DOM 中,所有 HTML 元素都被定义为对象。 HTML DOM 方法是您能够(在 HTML 元素上)执行的动作。 HTML DOM 属性是您能够设置或改变的 HTML 元素的值。 document.getElementById("demo")

Add onclick event to SVG element

主宰稳场 提交于 2020-02-11 07:10:06
问题 I found this example in a SVG tutorial that explains how you can use an onclick event handler for a SVG element. It looks like the code below: <svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='600' width='820'> <script type="text/ecmascript"><![CDATA[ function changerect(evt) { var svgobj=evt.target; svgstyle = svgobj.getStyle(); svgstyle.setProperty ('opacity', 0.3); svgobj.setAttribute ('x', 300); } ]]> </script> <rect onclick='changerect(evt)' style='fill:blue;opacity:1' x='10'

一篇习得XML

和自甴很熟 提交于 2020-02-10 21:52:49
一、什么是XML XML 指可扩展标记语言(EXtensible Markup Language) XML 是一种标记语言,很类似 HTML XML 的设计宗旨是 传输数据 ,而 非显示数据 XML 标签 没有被预定义 。您 需要自行定义标签 。 XML 被设计为具有自我描述性。 XML 是 W3C 的推荐标准 二、html与xml的区别 XML 不是 HTML 的替代。 XML 和 HTML 为不同的目的而设计: XML 被设计为传输和存储数据,其焦点是 数据的内容 。 ​ HTML 被设计用来显示数据,其焦点是数据的外观 。 ​ HTML 旨在显示信息,而 XML 旨在传输信息。 ​ HTML语法比较松散,xml语法严格 ​ HTML所有标签都是预先定义好的, 使用固定的标签,展示不同的内容 ​ XML当中的标签都是 自己定义 的 ​ XML用处, 数据存储、配置文件、数据传输 ​ 三、XML的基本语法 1、文档声明 可以添加以下属性 version版本号,固定1.0 encoding指定文档的码表 默认iso-8859-1 standalone指定文档是否独立yes或no是否可以引用其它文件 注:文档声明 必须放在第一行 2、规则 所有 XML 元素都 须有关闭标签 XML 标签对 大小写敏感 XML 必须 正确地嵌套 XML 文档 必须有根元素 XML 的 属性值须加引号

Add an element to the DOM with JavaScript

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-10 01:50:48
问题 I want add an element with JavaScript. I have the following code: var collection = document.getElementsByTagName('body'); var a = document.createElement('div'); a.innerHTML = 'some text'; collection.item(0).firstChild.appendChild(a); and simple HTML: <html> <head></head> <body> </body> </html> Where is mistake? 回答1: This should do what you are looking for: var newdiv = document.createElement("div"); newdiv.appendChild(document.createTextNode("some text")); document.body.appendChild(newdiv);

Add an element to the DOM with JavaScript

断了今生、忘了曾经 提交于 2020-02-10 01:50:20
问题 I want add an element with JavaScript. I have the following code: var collection = document.getElementsByTagName('body'); var a = document.createElement('div'); a.innerHTML = 'some text'; collection.item(0).firstChild.appendChild(a); and simple HTML: <html> <head></head> <body> </body> </html> Where is mistake? 回答1: This should do what you are looking for: var newdiv = document.createElement("div"); newdiv.appendChild(document.createTextNode("some text")); document.body.appendChild(newdiv);

Vue.js中this.$nextTick()的使用

纵饮孤独 提交于 2020-02-10 00:12:51
this.$nextTick()将回调延迟到下次 DOM 更新循环之后执行。在修改数据之后立即使用它,然后等待 DOM 更新。它跟全局方法 Vue.nextTick 一样,不同的是回调的 this 自动绑定到调用它的实例上。 假设我们更改了某个dom元素内部的文本,而这时候我们想直接打印出这个被改变后的文本是需要dom更新之后才会实现的,也就好比我们将打印输出的代码放在setTimeout(fn, 0)中; 先来第一个例子看一看 <template> <section> <div ref="hello"> <h1>Hello World ~</h1> </div> <el-button type="danger" @click="get">点击</el-button> </section> </template> <script> export default { methods: { get() { } }, mounted() { console.log(333); console.log(this.$refs['hello']); this.$nextTick(() => { console.log(444); console.log(this.$refs['hello']); }); }, created() { console.log(111); console.log

What does the second argument to $() mean?

瘦欲@ 提交于 2020-02-09 17:24:46
问题 I have a jQuery code as follows; var favorites = $("#favorites"); var favoritesFooter = $("#favoritesFooter",favorites); I am not sure what does the comma mean in the 2nd statement $("#favoritesFooter",favorites); Also what would the following statement do or represent in the above case; favoritesFooter.prev().after(newHTML); 回答1: The second statement means "search for element with ID of favoritesFooter inside the jQuery object favorites ". As you're dealing with ID which should be unique, it

What does the second argument to $() mean?

坚强是说给别人听的谎言 提交于 2020-02-09 17:23:52
问题 I have a jQuery code as follows; var favorites = $("#favorites"); var favoritesFooter = $("#favoritesFooter",favorites); I am not sure what does the comma mean in the 2nd statement $("#favoritesFooter",favorites); Also what would the following statement do or represent in the above case; favoritesFooter.prev().after(newHTML); 回答1: The second statement means "search for element with ID of favoritesFooter inside the jQuery object favorites ". As you're dealing with ID which should be unique, it

What does the second argument to $() mean?

你离开我真会死。 提交于 2020-02-09 17:20:57
问题 I have a jQuery code as follows; var favorites = $("#favorites"); var favoritesFooter = $("#favoritesFooter",favorites); I am not sure what does the comma mean in the 2nd statement $("#favoritesFooter",favorites); Also what would the following statement do or represent in the above case; favoritesFooter.prev().after(newHTML); 回答1: The second statement means "search for element with ID of favoritesFooter inside the jQuery object favorites ". As you're dealing with ID which should be unique, it