当前位置:网站首页>Webapi interview question summary 01
Webapi interview question summary 01
2022-07-04 08:34:00 【End to end 1023】
1. What is? dom?
1、DOM yes W3C( World wide web consortium ) Standards for
2、DOM Access defined HTML and XML Standards of documents
W3C DOM The standard is divided into 3 Different parts
The core DOM - A standard model for any structured document
XML DOM - in the light of XML Standard model for documentation
HTML DOM - in the light of HTML Standard model for documentation
remarks :DOM yes Document Object Model( Document object model ) Abbreviation
2. dom Node Attribute and Property What's the difference ?
1、 What is? Property
Every DOM All nodes are one object object , Have their own property and method In principle, property Should only js fuck do , Will not appear in html in ( Silent recognize Belong to sex except Outside : id/src/href/className/dir/title/lang etc. ), And others js object equally , Self defined property It will also appear in object Of for…in Ergodic
2、 What is? Attribute
attribute Appear in the dom in ,js Provides getAttribute/setAttribute And other methods to get and change its value , Finally, it acts on html in , Can affect innerHTML Get the value of . Can be accessed by dom Node attributes Property to get Change all of the nodes attribute.( stay IE<9 in ,attribute What gets and changes is actually property.)
3、 The difference between the two
3.1) Self defined Property And Attribute Out of sync , It's not equal
3.2) Non custom DOM property And attributes Is conditionally synchronized
3.3) Non custom properties (id/src/href/name/value etc. ), adopt setAttribute Modifying its property value can synchronously affect property On , And by .property Modify the attribute value (value) Time will not sync to attribute On , That is, it will not react to html On ( Except for the following situations , Non custom properties It is synchronous between the two ).
3. dom How structure operations are added 、 remove 、 Move 、 Copy 、 Create and find nodes ?
1、 Create a new node
createDocumentFragment() // Create a DOM fragment
createElement() // Create a specific element
createTextnode() // Create a text node
2、 add to 、 remove 、 Replace 、 Insert
appendChild()
removeChild()
replaceChild()
insertBefore() // did not insertAfter()
3、 lookup
getElementsByTagName() // By label name
getElementsByName() // By element Name The value of the property (IE Strong fault tolerance , You get an array , These include id be equal to name It's worth it )
getElementById() // Through elements Id, Uniqueness
4. dom Event model ?
DOM Event model
DOM There are two kinds of event models : Event capture and event bubbling .
Event capture takes click event as an example , Events of the same type will be caused by root —> The ancestor element of the target —> The parent element of the target —> Target element
Event bubbling is the opposite of event capture . Trigger from inside to outside : Target element —> The parent element of the target element —> Paternity The parent element of element —> root
Event communication
Both event capture and event bubble have event propagation stage , The propagation stage is the process from the beginning to the end of the event .
priority : Capture first , Bubble again .
5. What is event bubbling , How it works ? How to prevent events from bubbling 、 Default behavior ?
1、 What is event bubbling , How he works ?
Trigger some kind of event on an object ( For example, click onclick event ), This event will propagate to the parent object of this object , From inside to outside , Until it's dealt with ( All events of the same kind of the parent object will be activated ), Or it reaches the top of the object hierarchy , namely document object ( Some browsers are window)
2、 Methods to prevent event bubbling
2.1)w3c The method is event.stopPropagation(); Event handling , Stop bubbling , But it will not prevent default behavior ( Jump to hyperlink )
2.2)IE Is the use event.cancelBubble = true Stop the event from bubbling
2.3)return false; jq In the event processing process , Stop bubbling , Also block default behavior ( Do not jump over link )
function bubbles(e) {
var ev = e || window.event
if (ev && ev.stopPropagation) {
// Not IE browser
ev.stopPropagation()
} else {
// IE browser (IE11 following )
ev.cancelBubble = true
}
console.log(" The bottom box was clicked ")
}
3、 Ways to prevent default behavior
3.1)w3c Approach is to e.preventDefault()
3.2)IE Is the use e.returnValue = false;
// Suppose there is a link <a href="http://baidu.com/" id="testA" >baidu.com</a>
var a = document.getElementById("testA")
a.onclick = function (e) {
if (e.preventDefault) {
e.preventDefault()
} else {
window.event.returnValue == false;
}
}
边栏推荐
- Take you to master the formatter of visual studio code
- How college students choose suitable computers
- Leetcode 146. LRU 缓存
- Display Chinese characters according to numbers
- [Chongqing Guangdong education] National Open University spring 2019 455 logistics practice reference questions
- Group programming ladder race - exercise set l1-006 continuity factor
- ctfshow web255 web 256 web257
- C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码
- 广和通高性能4G/5G无线模组解决方案全面推动高效、低碳智能电网
- Guanghetong's high-performance 4g/5g wireless module solution comprehensively promotes an efficient and low-carbon smart grid
猜你喜欢
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
OpenFeign 服务接口调用
一文了解數據异常值檢測方法
What if the wireless network connection of the laptop is unavailable
ctfshow web255 web 256 web257
How to solve the problem that computers often flash
[gurobi] establishment of simple model
1、卡尔曼滤波-最佳的线性滤波器
Comparison between sentinel and hystrix
The second session of the question swiping and punching activity -- solving the switching problem with recursion as the background (I)
随机推荐
Flutter 集成 amap_flutter_location
What determines vacuum permittivity and vacuum permeability? Why do these two physical quantities exist?
Cancel ctrl+alt+delete when starting up
ctfshow web255 web 256 web257
deno debugger
1、卡尔曼滤波-最佳的线性滤波器
[test de performance] lire jmeter
Put a lantern on the website during the Lantern Festival
C # implements a queue in which everything can be sorted
Need help resetting PHP counters - PHP
How can we make a monthly income of more than 10000? We media people with low income come and have a look
C#实现一个万物皆可排序的队列
Use preg_ Match extracts the string into the array between: & | people PHP
yolov5 xml数据集转换为VOC数据集
真空介电常数和真空磁导率究竟是由什么决定的?为何会存在这两个物理量?
The right way to capture assertion failures in NUnit - C #
Chrome is set to pure black
Moher College phpmailer remote command execution vulnerability tracing
Flutter integrated amap_ flutter_ location
Call Baidu map to display the current position