当前位置:网站首页>JS new challenges
JS new challenges
2022-07-03 13:54:00 【The nth day of not loving oranges】
A month HTML, Whether it's pc Neither end nor mobile end can escape from the fixed structure and syntax , The degree of acceptance is still ok, Then it began to enter the second stage JavaScript Learning from , Just four days' content is enough to sigh . The difficulty of the course itself , The rhythm of the teacher's class , A day or two before a week can be compared to flying , The next threeorfour days can be called riding a rocket , Abet ~~ Be stunned . This week I mainly studied :
One 、JavaScript summary
JavaScrip abbreviation JS, Is running on the 【javascript Interpreter perhaps In a specific engine 】 Of 【 interpreted 】【 Weak type 】【 object-oriented 】 Scripting language
1、javascript Interpreter :
1、 Browser comes with js Interpreter
2、 Install one separately js Interpreter - node.js when
2、 A compiled : Before running the program , You need to check whether the grammar is correct , If it is incorrect, it is not allowed to run , such as :java、c、c++、c# - More stringent
Interpreter : Before running the program , Don't check whether the grammar is correct , Direct operation , If there is an error, it will stop running , such as :javascript、php、node.js... - More freedom
3、js characteristic :
1、 Code can be written with any text editor :vscode hbuilder Notepad ...
2、 Explanatory language , No need to compile
3、 Weak type language : There is no need to specify , Put whatever you want - Love freedom
The data type of a variable is determined by its value
4、js effect :
1、 Calculation of client data : The shopping cart
2、 Data validation of forms :( cell-phone number 、 Id card 、 mailbox 、 password )
3、 Provides events ( Click on 、 Move the mouse in and out 、 keyboard ...)
4、 Everything on the web css Special effects that cannot be done , All by js complete
5、 Interact with the server side ajax
Two 、JavaScript Use
1、 Usage mode :2 individual
1、 stay HTML Write a label on the page :
<script>
js Code
</script>
2、 Create a xx.js file , Write in it js Code , Last in HTML The page introduce
<script src="xx.js File path "></script>
2、JS Debug statement for : During code execution , If there's a mistake , Will report a mistake , But the subsequent code will not be executed , Even if it's just a logical error, not a grammatical error , That won't be wrong , We need a way to help us find out what's wrong
*1、 Log output at the console :console.log( What you want to output );// Piling output , Crazy piling
2、 Output on the page :document.write( What you want to output ); - Not to mention , If the event is bound , It will replace all the contents on the page
3、 The pop-up box shows :alert( What you want to output ); - The whole page will be blocked , Users cannot see it until it is closed HTML and CSS
3、js Grammatical norms of : It is strictly case sensitive , Don't Scribble
such as :
console.log();// correct
console.Log();// error
3、 ... and 、JavaScript The sentence of
1、while loop :
grammar :
var Loop variable = A few ;
while( The loop condition ){
The loop body ;
Changes in loop variables ;
}
2、for loop : and while What you can do is exactly the same , It's just that grammar is better than while It's simpler , It also looks more comfortable
grammar :
for(var Loop variable = A few ; The loop condition ; Changes in loop variables ){
The loop body ;
}
3、if structure :
1、 One condition, one thing , If you are satisfied, do it. If you are not satisfied, do not do it
if( Conditions ){
operation
}
2、 A condition 2 thing , If you are satisfied, do 1 dissatisfaction 2
if( Conditions ){
1
}else{
2
}
3、 Multiple conditions, multiple things , Do what you want
if( Conditions 1){
1
}else if( Conditions 2){
2
}else{
3
}
4、***** Array :
1、 Create array :2 Ways of planting
*1、 Direct measurement :var arr=[];// An empty array
var arr=[ Elements , Elements ,...];
2、 Constructor method :var arr=new Array();// An empty array
var arr=new Array( Elements , Elements ,...);
3、 ... and 、JavaScript The composition of
1、DOM Trees :DOM take HTML As an upside down tree structure , But the roots are not what you understand HTML label
* The root : It's a document object ,document Objects do not need to be created by our programmers , By the browser JS Interpreter creation , There is only one page document
effect : Provides some properties and methods , We programmers can operate the whole DOM Trees ( Add, delete, modify and check each DOM node )
DOM node : A label 、 Text 、 attribute 、 Elements
2、 Look for the element :
1、 adopt HTML Features to find elements
1、id lookup :var elem=document.getElementById("id value "); // Single element
2、 Tag name search :var elems=document/ Found parent element .getElementsByTagName(" Tag name "); // group
*3、class lookup :var elems=document/ The father who has been found .getElementsByClassName(" Tag name "); // group
2、 Find the relationship between nodes : Premise : You have to find someone first , To use relationships
Father :elem.parentNode;// Single element
Son :elem.children;// aggregate
The first son :elem.firstElementChild;// Single element
The last son :elem.lastElementChild;// Single element
The last brother :elem.previousElementSibling;// Single element
The latter brother :elem.nextElementSibling;// Single element
3、 Operational elements :
1、 Content :
*1、innerHTML attribute : obtain or Set up The content of an element , And can identify labels
Get content :elem.innerHTML;
Set contents :elem.innerHTML=" New content ";
2、innerText attribute : obtain or Set up The text of an element , The label cannot be recognized
Get content :elem.innerText;
Set contents :elem.innerText=" New content ";
3、value attribute : Specifically for single label (input) Operation content preparation
Get content :input.value;
Set contents :input.value=" New content ";
2、 attribute :
1、 Get attribute value :elem.getAttribute(" Property name ");
2、 Setting property values :elem.setAttribute(" Property name "," Property value ");
simplify :
1、 obtain :elem. Property name ;
2、 Set up :elem. Property name =" Property value ";
defects :1、 Cannot manipulate custom attributes , Only standard properties can be manipulated
2、class stay ES6 Upgrade to a keyword , So I want to write class In exchange for className
3、 style :
grammar :
obtain :elem.style.css Property name ;
Set up :elem.style.css Property name ="css Property value ";
special :1、css Property name , Where there is a horizontal line , Change to the small hump nomenclature
2、 At the time of acquisition , Dai Laoshi only handed over to everyone to get the inline style , Cannot get styles in style sheet
4、 Element binding events :
Single element :elem.οnclick=function(){
operation ;
this-> Single element binding event ,this->elem Bind this element of the event
}
Multiple elements :for(var i=0;i<elems.length;i++){
elems[i].οnclick=function(){
operation
this-> Multiple element binding events ,this-> The element that currently triggers the event
}
}
*** summary :
1、 All acquisition is for judgment
2、 All settings are for modification
3、 Never operate on a set , Or traverse to get all , Or take a subscript
边栏推荐
- 使用Tensorflow进行完整的深度神经网络CNN训练完成图片识别案例2
- HALCON联合C#检测表面缺陷——HALCON例程autobahn
- How to promote the progress of project collaboration | community essay solicitation
- [技术发展-24]:现有物联网通信技术特点
- [bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
- Heap structure and heap sort heapify
- Implementation of Muduo accept connection, disconnection and sending data
- 怎样删除对象的某个属性或⽅法
- Sequence table (implemented in C language)
- Qt学习19 Qt 中的标准对话框(上)
猜你喜欢
Flutter动态化 | Fair 2.5.0 新版本特性
[email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂"/>
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Go language unit test 3: go language uses gocovey library to do unit test
Spring cup eight school league
Flutter dynamic | fair 2.5.0 new version features
SQL Injection (POST/Search)
掌握Cypress命令行选项,是真正掌握Cypress的基础
The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can
CVPR 2022 | interpretation of 6 excellent papers selected by meituan technical team
Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS
随机推荐
解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
挡不住了,国产芯片再度突进,部分环节已进到4nm
又一个行业被中国芯片打破空白,难怪美国模拟芯片龙头降价抛售了
Uniapp skills - dom display and hiding
SQL Injection (AJAX/JSON/jQuery)
Mysql:insert date:SQL 错误 [1292] [22001]: Data truncation: Incorrect date value:
PhpMyAdmin stage file contains analysis traceability
Mastering the cypress command line options is the basis for truly mastering cypress
Use docker to build sqli lab environment and upload labs environment, and the operation steps are provided with screenshots.
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
Qt学习25 布局管理器(四)
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
Field problems in MySQL
JS general form submission 1-onsubmit
Record 405 questions about bank callback post request
Function calling convention
[how to solve FAT32 when the computer is inserted into the U disk or the memory card display cannot be formatted]
3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)
Uniapp tips - set background music