Articles Catalogue
HTML
- Html tag library (building blocks, ugly interface)
- Pseudo-XML specification
- Only one root node
- Each node (multiple sub-nodes, multiple attributes, content)
- Each node (open node, closed node)
- Label Framework (html, head, body)
- According to HTML 5 standard
- head: Non-display, set line labels
- body: the display content of the document
- Label type:
-
Basic label
1. <a href= "http://www.baidu.com" target="_new">Baidu</a>
href: target address; target: page display location
2. <img src="a.jpg" width="250px" height="400px">
img can lead to image stretching, which is not suitable for background. -
Panel Label
1. <div> </div> (block element)
2. <span> </span> (in-line elements) -
Data Label (Form Label)
-
<form>
- Action Data Submission Address
- The types of Method requests get, post
a) Get information on the address bar
b) Post information on the body of the protocol
-
<input>
- Type control type
- Value parameter value
- < Select > drop-down list
- < textares > multiline text
- Table > Table Data Display
-
<form>
-
Location label
- <p> Content </p> Paragraph
- <br> Next line
- & nbsp space
-
Effect label
- <b> bold type
- <h1>... Title < H5 >
-
List label
- < ol > < li > < / Li > < / OL > ordered list
- < UL > < li > < / Li > < / UL > unordered list
-
CSS
- Cascading Style Sheet
color: red;background-color: green;-
Attribute: Style;
-
Color settings:
color: red;
Color: f00/ ff0000; (RGB color value)
color:rgba(255,0,0,0.5); (a: transparency)
Priority:
Range of choice (the larger the range, the smaller the priority)
Loading order (priority of subsequent loading)
Specific priority (! important) -
usage
-
In-line use (current label is valid, priority is high, exceptional use)
<a href="" style= "color: red; background-color: green;">legalization</a> -
Intra-page use
<style type="text/css"> a{ /* color:red; */ /* color: #f00; */ color:rgba(255,0,0,0.5); background-color: green;" } </style>
-
Out-of-page use (selector writes files to support browser caching)
<link href="a.css" rel="stylesheet">
-
-
Selector (Select Style Implementation Labels)
-
a {} Label Selector
-
# a {} id selector id attribute value (unique in the page)
-
Class attribute value of. aa {} class selector (multiple settings)
<a class="a11 back" href="#">111</a> -
[aaa='a1'] attribute selector (if the attribute value is numeric or Chinese, single quotation marks must be added)
<a aaa="a1" href="#">222</a> [aaa=a1]{ color:green; }
-
a, div {} or selectors a and div are valid
-
Div a {} home selector (all a tags in the div tag)
-
Div > a {} descendant selector (direct descendant a tag in div tag)
-
hover pseudoclass (label status selector)
-
-
box model + location
- Margin: Outer margin (fine-tuned position, occupied in-situ position)
- border: border (Settings: Color, Style, Thickness)
- padding: Internal margin (content location changes, may lead to size changes)
- position+left+right+bottom+top location
- position: fixed super absolute positioning (ignoring the hierarchy, positioning by the top left corner of the document, a separate layer)
- position: absolute positioning (the most commonly used positioning, positioning according to the upper left corner of the upper container, the upper container is also absolute positioning)
iii. position: relative relative relative positioning (positioning in situ)
-
Common attributes
- Display display mode (none, block, inline)
- visibility: hidden invisible hiding
- float: alignment and positioning
- Cursor: cursor
- outline: none; hides the input focus border
- z-index: Setting the priority of overlapping tag styles
- overflow: solution beyond scope
-
Simple css3
- css3 effect generator generator
-
Additional Framework and Use
- Animate.css
- Buttons.css
-
JavaScript
- Not java, do page interaction (animation, events)
usage
-
Events, in-line usage
<a href="#" onclick="alert(11)">lhy</a>
-
In page
<script> function ok(){ alert(11) } </script>
-
Out of page
<script type="text/javascript" src="js/my.js" ></script>
Grammar (Weak Type)
var a = 100;/*Definition of variables*/ var b = "qwe"; //Change variables at any time c = "123"; //var can be omitted d = {1,2,3,4};/*array define*/ e = {name:"123",sex:2};/*Object Definition*/ alert(e.name); //Object attributes function add(a,b){/*Function definition, no return value, no type of parameter*/ return a+b; } function add(a,b,c){ if(!b)b=100; //Judge null, undefined, false return c(a,b); } var fun = function(a,b,c); //Variable value is function fun(11,22,function(c,d){ //Anonymous function alert(c+d); })
null (empty), NaN (calculation failure), undefined (illegal operation, undefined)
BOM
- Browser Object Model
- navigator: Browser Basic Information (Browser Compatibility)
- navigator.product
- Screen: User Screen Information
- screen.deviceXDPI
- History: Browser History
- history.back(): equivalent to clicking the back button in the browser
- history.forward(): the same as clicking the forward button in the browser
- history.length; browser history
- Location: Get the current page address (URL) and redirect the browser to a new page
- location.reload: refresh
- locating.href: Go to the destination address
- window: Superior to all BOM objects
-
Window method:
window.open("http://www.baidu.com","_self");
window.open("index.html","_new","width:100px;height:100px");
this.resizeTo(300,500);
this.close();
window.moveTo();
window.scrollBy(); -
Dialogue box method
alert() ;//MsgBox if(confirm("yes/no")) //Option Dialog alert("yes"); var str = prompt("input"); //Enter dialog box alert(str);
-
timer
var pos; function ok(){ pos = setTimeout(function(){ alert("ok"); },3000) } function size(){ clearTimeout(pos); }
-
DOM
document object model: document object template (each tag is an object)
-
Getting objects
-
The label id attribute is a variable name
mydiv.innerHTML = " ";
-
Using getElementById
var d = document.getElementById("my");
d.innerHTML = "111"; -
Use
var d = document.getElementsByTagName();
d[0].innerHTML = "111"; -
Use
var d = document.getElementsByClassName();
d[0].innerHTML = "111";
-
-
Modify objects
- value/input
- name
- innerHTML
- style
- class classList
d[1].style.color="#0f0 "; // Manipulate css
var left = d[1].offsetLeft;//read-only
-
Create and delete
-
Additional label
-
First
var d = document.getElementsByTagName("div");
var a = document.createElement("a");
a.href = "#";
a.innerText = "My";
d[0].appendChild(a); -
Second
var d = document.getElementsByTagName("div");
d[0].innerHTML = "qwe";
-
-
delete a tap
var d = document.getElementsByTagName("a");
d[1].parentElement.removeChild(d[1]); -
Event: (Bubble Event: Click on child tag, parent tag linkage response)
- onclick = ok; // tag add event
- window.onload = function()//js script joins events
- Event object, event object (public event)
- this object, event source itself
-
Object-oriented
var user={name:"lhy",sex:1,mov:function(x,y){ alert(x+y); },sub:[2,12,"233"]}; //prop alert(user.name); user.mov(10,11); alert(user.sub[2]);
function user(name){ //Class, Construction Method this.name = name; //Instance variables this.mov = function(){ //Example method add(); } function add(){ //Private methods alert(sex); } var sex = 0; //private variable } var u = new user("lhy"); u.mov();
- inherit
- Prototype Inheritance
function user(){ } user.prototype.age=100; var u = new user(); alert(u.age);
- call inheritance
function user(){ this.age=21; } function myuser(){ user.call(this); this.name="lhy"; } var u = new myuser(); alert(u.name) alert(u.age);
Cavas: Drawing pictures
debugging
- console.log(), equivalent to syso output
ajax
- Asynchronous Javascript And XML (Asynchronous Javascript And XML or HTML)
- Asynchronous request (web server), non-refresh request
- Steps:
- var hr = new XMLHttpRequest(); // Create
- hr.open("GET", "js/a.json"); //settings
- hr.send(); // send, send with parameters
- hr.onreadystatechange; // status change
function sendmsg(){ var hr = new XMLHttpRequest(); //Establish hr.open("GET","js/a.json"); //Set up hr.send(); //Send with parameters hr.onreadystatechange=function(){ if(hr.readyState==4){ //Judgment of state var str = hr.responseText; //Response content var obj = eval("("+str+")");//json object to prop mya.innerText = obj.name; } } console.log() }
- Asynchronous request processing:
- Define onreadystatechange before sending
- json:
- Consistent with the prop object, no method can be added
- Key value must be added ", value, number, Boolean can not be added";
- Characters: {} - Objects; [] - Arrays; Keys: Values; Keys: Values; Arrays and Objects can be infinitely nested
Bootstrap (css framework)
- cdn server: content distribution network
- css custom style (control, label)
- css grid (dynamic layout)
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
- Root container:
- container (fixed width)
- container-fluid (100% width)
- Create rows and manipulate columns (columns do not need to be created, 12 columns)
<div class="row"> //Each row <div class="col-md-6 col-sm-10" style="height: 100px;background: #f0f;"></div> <div class="col-md-6 col-sm-2" style="height: 100px;background: #f00;"></div> </div>
Unable to place (12 columns exceed) automatic Line-Changing
- Cleafix: Columns may appear higher than other columns, column height alignment
- con-mod-4: Shift the column to the right
- col-md-push-3: column sorting
- hidden-xs: hiding
- visible-xs: Display
- js tool (control control control)
- jQuery Strong Dependency
jQuery (js Tool Library)
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
selector
- $("label /. class/#id")
Consistent with css selector
$("a")
Get the number of choices
$("a").length
Convert jQuery to JS tag object: $(js tag object) [index]
1. Index conversion
2. jQuery comes with get(index) conversion
var HtmlElement=$("div")[0];
Converting js objects to jQuery:$() is a jQuery object in brackets
var a = document.getElementById("aaa")
var aa = $("a")
alert(aa.length)
Method Continuous Use
var aa = ("a").add(("a").add(("a").add(("div")).add($("span"))
Selector container add, add when defining variables, otherwise add fails
var aa = ("a").add(("a").add(("a").add(("div"))
ergodic
var aa = ("a").add(("a").add(("a").add(("div"))
aa.each(function(i,o){ // i index, o per js object
alert(o)
})
retrieval
-
Superior
parent: first-level Supervisor
parents: selector queries along the superior to find eligibility$(o).parents("span").attr("aaa")
-
Brother
prev: The previous one
prevAll: All previous
next: the latter
Next All: Later All
siblings: Query all eligible brothers -
subordinate
children(expr): a layer of sub-elements, a direct child node
find(expr): All descendants of selectors are searched
contents(): Find all of the following, including nodes and text
dom operation
-
text(): (without reference) get + (with reference) set text;
-
HTML (html script): no parameters to get + (with parameters) setting content (including text, label);
-
Attr (attribute name, value): (a parameter) get attribute + (two parameters) set attribute value
-
prop (attribute name, value): same attr;
-
val (value): (no parameter) get + (parameter) set value property
-
css (prop object):
$(o).css({color:"red",background:"green"})
If there is a minus sign attribute:
1. "background-color" with quotation marks
2. backgroundColor, capitalized after minus sign -
css (attribute name, value): (a parameter) get attribute + (two parameters) set attribute value
$(o).css("color","red")
-
Add and delete
-
Add:
$(".aaa").html("<a href="#">lhy</a>")
var a = $("<a></a>").attr("href","#").text("Say what you say and divide it."); $(".aaa").append(a)
-
Delete:
$(".aaa").remove() //Delete oneself
$(".aaa").empty() //Empty oneself content
-
-
Loading completed
$(function(){
//window.onload, load ahead of time
}) -
Event:
- Stop bubbling
event.cancelBubble = true;
$(function(){ //$(".classname") $(document).bind("click",".aaa",function(){ event.cancelBubble = true; //Combining $("attribute value") to solve bubbling problem alert(1) }) })
- Stop bubbling
-
bind method: bind event ()
animation
-
Hide and display HTML elements
hide() and show()
-
Fade
fadeIn() fadeOut() fadeToggle() fadeTo()
-
Sliding effect
slideDown() slideUp() slideToggle()
$(".bbb").hide(5000,function(){ //Animation Time, Callback Method alert(1); });
-
Custom animation: animate()
$(".bbb").animate({width:"50px",height:"50px"},2000);
Ajax
$.post("a.json",{},function(json){
},"json");
$.ajax({ type: 'post', url: 'a.da', dataType: 'json', Return object type async:true, contentType:"application/x-www-form-urlencoded" 'application/json' Background processing json 'multipart/form-data' file data:{} Request parameters success:function(JSON){ //Result Processing }