当前位置:网站首页>7、 DOM (Part 2) - chapter after class exercises and answers
7、 DOM (Part 2) - chapter after class exercises and answers
2022-04-23 18:40:00 【Xiong xiansen's Treasure】
Chapter 1 links : First time to know JavaScript - Chapter after class exercises and answers
Chapter II links :JavaScript Basics ( On ) - Chapter after class exercises and answers
Chapter 3 links :JavaScript Basics ( Next ) - Chapter after class exercises and answers
Chapter 4 links :JavaScript function - Chapter after class exercises and answers
Chapter 5 links :JavaScript object - Chapter after class exercises and answers
Chapter 6 links :DOM( On ) - Chapter after class exercises and answers
notes : It is published by the people's post and Telecommunications Publishing House 《JavaScript+jQuery Interactive Web The front-end development 》 Books .
One 、 Completion
1、 The realization steps of exclusive thought are ______ And ______.
2、HTML 5 New through ______ Method to set custom properties .
3、HTML 5 Pass through ______ Get custom properties .
4、______ Attribute can get all the child element nodes of the element , It is a readable property .
5、DOM according to HTML Different functions of nodes in , Separate the comments in the document into ______.
Two 、 Judgment questions
1、 Use document.createElement() You can create element nodes .( )
2、 The keyboard event object is KeyBoardEvent.( )
3、 Low version of the IE browser (IE 6~IE 8) in , Can pass event Get event object .( )
4、appendChild() Method means to add a node to the child node list of the specified parent node .( )
5、cloneNode() Method returns a copy of the node that called the method , Also known as clone nodes .( )
3、 ... and 、 choice question
1、 In the following options , What you can do to create elements is ( ).
A. element.push('<p> Hello </p>')
B. element.pop('<p> Hello </p>')
C. element.innerHtml = '<p> Hello </p>'
D. document.createElement("p")
2、 About adding elements , The following options describe the error ( ).
A. innerHTML Will overwrite the original element
B. appendChild Is to append... Inside the parent element
C. insertBefore Is to add... At the specified position inside the parent element
D. createElement The created element is immediately added to the page
3、 About event objects , The wrong description is ( ).
A. The properties of the event object store a series of information related to the event
B. The event object will be generated when the event is triggered
C. There is a compatibility problem with the acquisition of event objects
D. Event bubbling and default behavior cannot be prevented through event objects
4、 Following options , The event objects compatible with each browser can be obtained correctly ( ).
A. document.onclick = function (event) { var e = window.event || event; }
B. document.onclick = function (event) { var e = window.evt || event; }
C. document.onclick = function (event) { var e = window.event || evt; }
D. document.onclick = function (event) { var e = window.evt || evt; }
5、 About event monitoring , The wrong description is ( ).
A. You can register multiple listeners for the same element and the same event
B. addEventListener() There is a browser compatibility problem
C. addEventListener() Method has two parameters
D. Low version of the IE have access to attachEvent Instead of addEventListener
Four 、 Short answer
1、 Please briefly introduce the general implementation steps of exclusive operation .
2、 Please explain childNodes and children The difference between .
5、 ... and 、 Programming questions
Complete the dynamic generation of table cases , The specific requirements are as follows .
- Use arrays to simulate student data .
- Dynamically create rows 、 Cell .
- Fill cells with data .
- Provide “ Delete ” link , You can delete the row .
The implementation effect of the case is shown in the figure below .
Refer to the answer :
One 、 Completion
1、 All elements are cleared Set current element
2、data- Property name
3、element.dataset. attribute ( or element.dataset[' attribute '] )
4、children
5、 Comment node
Two 、 Judgment questions
1、 Yes 2、 Yes 3、 Yes 4、 wrong 5、 Yes
3、 ... and 、 choice question
1、D 2、D 3、D 4、A 5、C
Four 、 Short answer
1、 Please briefly introduce the general implementation steps of exclusive operation .
answer : The first step is to : All elements are cleared ( Exclude others ( Including myself ))
The second step is : Set current element ( Set yourself the effect you want to achieve )
2、 Please explain childNodes and children The difference between .
answer :childNodes: Property gets a collection of all child nodes of the current element , The set is an instant update set
children: Is a readable property , Returns all child element nodes , Only child element nodes are returned , The remaining nodes do not return
5、 ... and 、 Programming questions
1、HTML The code is as follows :
<table cellspacing="0"> <thead> <tr> <th> full name </th> <th> subject </th> <th> achievement </th> <th> operation </th> </tr> </thead> <tbody> </tbody> </table>
2、JavaScript The code is as follows :
<script> // 1. First prepare the students' data var datas = [{ name: ' Zhang San ', subject: 'JavaScript', score: 100 }, { name: ' Li Si ', subject: 'JavaScript', score: 90 }, { name: ' Liu Wu ', subject: 'JavaScript', score: 90 }]; // 2. Go to tbody Inside, China Construction Bank : There are several people ( By the length of the array ) Let's just create a few lines var tbody = document.querySelector('tbody'); for (var i = 0; i < datas.length; i++) { // Outside for Circulation management line tr // 1. establish tr That's ok var tr = document.createElement('tr'); tbody.appendChild(tr); // 2. Create cells in rows ( Data related 3 A cell ) td The number of cells depends on the number of attributes in each object for Loop through objects datas[i] for (var k in datas[i]) { // Inside for Circulating pipe train td // Create cells var td = document.createElement('td'); // Put the attribute value in the object datas[i][k] to td // console.log(datas[i][k]); td.innerHTML = datas[i][k]; tr.appendChild(td); } // 3. Create or delete 2 A word cell var td = document.createElement('td'); td.innerHTML = '<a href="javascript:;"> Delete </a>'; tr.appendChild(td); } // 4. Delete operation started var as = document.querySelectorAll('a'); for (var i = 0; i < as.length; i++) { as[i].onclick = function() { // Click on a Delete At present a Where the line is ( Linked dad's Dad ) node.removeChild(child) tbody.removeChild(this.parentNode.parentNode) } } </script>
3、CSS The style code is as follows ( To display the effect consistent with the job screenshot, add CSS Code , Don't add CSS The code does not affect the function ):
<style> body{ width: 100%; margin: o auto; height: 300px; position: fixed; } table { width: 500px; height: auto; position: relative; left:50%; margin-left: -250px; justify-content: center; align-content: center; align-items: center; } tr{ display: flex; justify-content: center; align-content: center; align-items: center; border-bottom: 1px solid #333; text-align: center; } td, th { flex:1; } thead tr { height: 40px; background-color: #ccc; } </style>
版权声明
本文为[Xiong xiansen's Treasure]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231835332635.html
边栏推荐
- Promote QT default control to custom control
- SQL中函数 decode()与 replace()的用法
- 特征选择feature_selection--SelectKBest
- Kettle paoding jieniu Chapter 17 text file output
- Analysez l'objet promise avec le noyau dur (Connaissez - vous les sept API communes obligatoires et les sept questions clés?)
- Domestic GD chip can filter
- kettle庖丁解牛第17篇之文本文件输出
- Imx6 debugging LVDS screen technical notes
- Sentinel规则持久化进Nacos
- QT add external font ttf
猜你喜欢
Spark performance optimization guide
Resolution: cnpm: unable to load file \cnpm. PS1, because running scripts is prohibited on this system
Promote QT default control to custom control
ESP32 LVGL8. 1 - textarea text area (textarea 26)
ctfshow-web362(SSTI)
[popular science] CRC verification (I) what is CRC verification?
ESP32 LVGL8. 1 - label (style 14)
【数学建模】—— 层次分析法(AHP)
Cygwin64 right click to add menu, and open cygwin64 here
Introduction to quantexa CDI syneo platform
随机推荐
Quantexa CDI(场景决策智能)Syneo平台介绍
Analysez l'objet promise avec le noyau dur (Connaissez - vous les sept API communes obligatoires et les sept questions clés?)
Const keyword, variable and function are decorated with const
Promote QT default control to custom control
Kettle paoding jieniu Chapter 17 text file output
In shell programming, the shell file with relative path is referenced
昇腾 AI 开发者创享日全国巡回首站在西安成功举行
Machine learning practice - naive Bayes
Chondroitin sulfate in vitreous
Setting up keil environment of GD single chip microcomputer
深入理解 Golang 中的 new 和 make 是什么, 差异在哪?
ctfshow-web361(SSTI)
Daily CISSP certification common mistakes (April 11, 2022)
Daily CISSP certification common mistakes (April 14, 2022)
C language simulates entering and leaving the stack, first in first out, first in first out, shared memory
ESP32 LVGL8. 1 - slider slider (slider 22)
listener. log
Configure iptables
Imx6 debugging LVDS screen technical notes
特征选择feature_selection--SelectKBest