当前位置:网站首页>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;
}
}
边栏推荐
- 根据数字显示中文汉字
- 2022 examination questions for safety managers of metal and nonmetal mines (underground mines) and examination papers for safety managers of metal and nonmetal mines (underground mines)
- Comparison between sentinel and hystrix
- What does range mean in PHP
- 力扣今日题-1200. 最小绝对差
- The second session of the question swiping and punching activity -- solving the switching problem with recursion as the background (I)
- Leetcode 23. Merge K ascending linked lists
- How college students choose suitable computers
- L1 regularization and L2 regularization
- [gurobi] establishment of simple model
猜你喜欢
Call Baidu map to display the current position
zabbix监控系统自定义监控内容
Developers really review CSDN question and answer function, and there are many improvements~
[gurobi] establishment of simple model
Do you know about autorl in intensive learning? A summary of articles written by more than ten scholars including Oxford University and Google
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
zabbix監控系統自定義監控內容
Go h*ck yourself:online reconnaissance (online reconnaissance)
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
DM8 uses different databases to archive and recover after multiple failures
随机推荐
zabbix监控系统自定义监控内容
ZABBIX 5.0 monitoring client
团体程序设计天梯赛-练习集 L1-006 连续因子
How to set multiple selecteditems on a list box- c#
猜数字游戏
Sports [running 01] a programmer's half horse challenge: preparation before running + adjustment during running + recovery after running (experience sharing)
Unity text superscript square representation +text judge whether the text is empty
Common components of flask
Laravel page load problem connection reset - PHP
A single element in an ordered array
Leetcode 23. Merge K ascending linked lists
What does range mean in PHP
L1 regularization and L2 regularization
力扣今日题-1200. 最小绝对差
Group programming ladder race - exercise set l1-006 continuity factor
2022 tower crane driver examination and tower crane driver examination questions and analysis
根据数字显示中文汉字
Div hidden in IE 67 shows blank problem IE 8 is normal
Newh3c - routing protocol (RIP, OSPF)
Go h*ck yourself:online reconnaissance (online reconnaissance)