Today I learned DOM and did the following basic exercises...
DOM is the abbreviation of Document Object Model; use JavaScript to operate DOM for DHTML development.
Learning goal: Be able to use JavaScript to operate Dom to achieve common DHTML effects.
Reference book: Zhang Xiaoxiang's "JavaScript Web Development - Experiential Learning Tutorial"
1. Introduction to DOM:
1. DOM is the model of an HTML page. Each tag is treated as an object. JavaScript can programmatically control text boxes, layers and other elements in web pages by calling attributes and methods in the DOM. For example, by manipulating the DOM object of the text box, you can read and set the value in the text box.
2. DOM, like WinForm, can be programmed through events, properties, and methods.
3. CSS JavaScript DOM=DHTML (i.e. dynamic HTML, an extension of the HTML language. It can increase the presentation effect of documents and objects.)
2. Events:
1. Event:
:
2. Dynamically set events:
The event response function can be dynamically set in the code, just like "btn.Click=" in .Net.
> ;
1) The alert method pops up a message dialog box
2) The confirm method displays the "OK" and "Cancel" dialog boxes. If the [OK] button is pressed, it returns true, otherwise it returns false.
if(confirm("Continue?"))
{
alert("Confirm");
}
else
{ alert("Cancel");}
3) Navigate again to the specified address: navigate("http://www.microsoft.com/");
4) setInterval executes the specified code every once in a while, and the first parameter is the string of the code , the second parameter is the interval time (unit: milliseconds), and the return value is the timer ID. For example: setInterval("alert('hello')",5000);
5) clearInterval cancels the scheduled execution of setInterval, which is equivalent to Enabled=False in Timer. Because setInterval can set multiple timings, clearInterval must specify the identifier of the timer to clear, which is the return value of setInterval. var intervalld= setInterval("alert('hello')",5000);
clearInterval(intervalld);
6) setTimeout is also executed regularly, but it is not executed regularly like setInterval, but after the set time Only executed once, clearTimeout is also the clearing time.
It’s easy to distinguish: Interval means timing; Timeout means timeout. For example: var timeoutld=setTimeout("alert('hello')",2000);
Case: Realize the revolving effect of the title bar, that is, the title text of the browser scrolls to the right every 500ms. Tip: The title is the document.title attribute.
4. 1) onload: Triggered when the web page is loaded. The browser downloads the document while parsing and executing it. It may happen that a certain element needs to be operated when JavaScript is executed. This element has not been loaded. In this case, the operation must be performed. Put the code in the onload event of the body, or you can put the JavaScript after the element. The element's onload event is triggered when the element itself is loaded, and the onload in the body is when all loading is completed.
2) onunload: Triggered after the web page is closed (or left). Assign a value to "Window.event.returnValue" in the event (the warning message to be displayed), so that a confirmation message will pop up when the window is left (such as forward, backward, closed). For example:
5. Other events:
In addition to unique attributes, there are of course general HTML elements Events: onclick (click), ondblclick (double-click), onkeydown (key press), onkeyup (key release), onkeypress (click button), onmousedown (mouse press), onmousemove (mouse move), onmouseout (mouse leaves) element range),
onmouseover (mouse moves to element range), onmouseup (mouse button release), etc.
3. Properties of the window object
1. window.location.href="http://www.sina.com.cn", redirecting to a new address, has the same effect as the navigate method. window.location.reload() refreshes the page.
2. window.event is a very important attribute, used to obtain information when an event occurs. Events are not limited to events of the window object. Events of all elements can obtain relevant information through the event attribute.
1) altKey attribute, boot type, indicates whether the alt key is pressed when an event occurs. Similar attributes include ctrlKey and shiftKey. For example, ;
2) clientX, clientY are the coordinates of the mouse in the client area when events occur; screenX, screenY are the coordinates of the mouse on the screen when events occur; offsetX, offsetY are when events occur relative to the mouse relative to the event source (for example, onclick is triggered when a button is clicked) coordinates.
3) returnValue attribute. If returnValue is set to false, the processing of the default event will be cancelled.
4) srcElement: Get the event source object
5) KeyCode: The key value when the time occurs
6) button: The mouse button when the time occurs, 1 is the left button, 2 is the right button, 3 is the left button keys simultaneously.

PHP学习笔记:数据结构与算法概述:数据结构和算法是计算机科学中非常重要的两个概念,它们是解决问题和优化代码性能的关键。在PHP编程中,我们常常需要使用各种数据结构来存储和操作数据,同时也需要使用算法来实现各种功能。本文将介绍一些常用的数据结构和算法,并提供相应的PHP代码示例。一、线性结构数组(Array)数组是最常用的数据结构之一,可以用来存储有序的数据

1.原生js获取DOM节点:document.querySelector(选择器)document.getElementById(id选择器)document.getElementsByClassName(class选择器)....2.vue2中获取当前组件的实例对象:因为每个vue的组件实例上,都包含一个$refs对象,里面存储着对应的DOM元素或组件的引用。所以在默认情况下,组件的$refs指向一个空对象。可以先在组件上加上ref="名字",然后通过this.$refs.

在网页开发中,DOM(DocumentObjectModel)是一个非常重要的概念。它可以让开发者轻松地对一个网页的HTML或XML文档进行修改和操作,比如添加、删除、修改元素等。而PHP中内置的DOM操作库也为开发者提供了丰富的功能,本文将介绍PHP中的DOM操作指南,希望可以帮助到大家。DOM的基本概念DOM是一个跨平台、独立于语言的API,它可以将

dom是一种文档对象模型,同时也是用于html编程的接口,通过dom来操作页面中的元素。DOM是HTML文档的内存中对象表示,它提供了使用JavaScript与网页交互的方式。DOM是节点的层次结构(或树),其中document节点作为根。

vue3ref绑定dom或者组件失败原因分析场景描述在vue3中经常用到使用ref绑定组件或者dom元素的情况,很多时候,明明使用ref绑定了相关组件,但是经常ref绑定失败的情况。ref绑定失败情况举例ref绑定失败的绝大多数情况是,在ref和组件绑定的时候,该组件还未渲染,所以绑定失败。或者组件刚开始未渲染,ref未绑定,当组件开始渲染,ref也开始绑定,但是ref和组件并未绑定完成,这个时候使用组件相关的方法就会出现问题。ref绑定的组件使用了v-if,或者他的父组件使用了v-if导致页面

dom和bom对象有:1、“document”、“element”、“Node”、“Event”和“Window”等5种DOM对象;2、“window”、“navigator”、“location”、“history”和“screen”等5种BOM对象。

bom和dom在作用和功能、与JavaScript的关系、相互依赖性、不同浏览器的兼容性和安全性考虑等方面都有区别。详细介绍:1、作用和功能,BOM的主要作用是操作浏览器窗口,它提供了浏览器窗口的直接访问和控制,而DOM的主要作用则是将网页文档转换为一个对象树,允许开发者通过这个对象树来获取和修改网页的元素和内容;2、与JavaScript的关系等等。

PHP学习笔记:论坛与博客系统开发在Web开发领域中,论坛和博客系统是非常常见的应用程序。它们为用户提供了一个交流和分享信息的平台。在本篇文章中,我们将讨论如何使用PHP开发一个简单的论坛和博客系统,并附上具体的代码示例。环境设置首先,我们需要搭建一个适合PHP开发的开发环境。我们可以使用AMP(Apache、MySQL和PHP)软件包,如XAMPP或WAM


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools
