《The Missing Manual Javascript 》 - 书摘精要
(P23) < script type = "text/javascript "> ***** </ script >
(P26) < script type = "text/javascript " src = "sample.js"></ script >
(P61)
“push()” —— 在数据最后添加;
“unshift()” —— 在数组头部添加;
(P63)
“pop()” —— 从数组尾部删除;
“shift” —— 在数据头部删除;
(P64) “Splice()” —— 指定位置添加或删除;
(P103) A function can only return one value;
(P117) navigator.userAgent
(P119) string.slice(start, end); (end --> last letter's position + 1);
(P131) In Jav script , a null value is treated the same as false;
(P132) string.replace(regex, 'replace');
(P135)
Number();
parseInt() —— will try to change even a string with letters to a number, as long as the string begins will numbers.
(P137)
“Math.ceil()” —— Up
“Math.floor” —— Down
(P138) Math.random();
(P140) new Date() retrieves the current time and date as determined by each visitor's computer;
(P172) $('selector')
(P176)
Descendent Selectors —— $('#navBar a')
Child Selectors —— $('body > p')
Adjacent Selectros —— $('h2 + div')
Attribute Selectors —— $('img[alt]') $('Input[type=text]')
[attribute ^= value] —— attribute begins with a value;
[attribute $= value] —— attribute ends with a value;
[attribute *= value] —— attribute contains a value anywhere;
(P178)
:even —— Odd
:not() —— $('a:not(.navButton)');
:has() —— $('li:has(a)');
:contains() —— $('a:contains(click Me!)');
:hidden —— $('div:hidden').show();
:visible
(P181)
.html() —— works like DOM's innerHTML property;
.text() —— actually display the brackets and tag names on the page;
.append() —— add HTML as the last child element of the selected element;
.prepend() —— add HTML as the last child element of the selected element;
.before() .after() —— outside of a selection, either before or after;
(P183) .remove() —— removema selected element;
(P194) .clone() —— make a copy of a selected element;
(P185)
.addClass() —— add a special class to an element;
.removeClass() —— remove a special class from an selected elements;
.targetClass() —— add or remove;
(P186) .css() —— var brColor = $('#main').css('background-color');
(P190)
.attr() —— let you read a specified HTML attribute. let you set the attribute;
.removeAttr() —— remove an attribute;
(P191)
$(document).ready(function() { ...... }); —— make sure that the HTML for the page has loaded before your Java script program runs;
(P193)
$('img').fadeOut() —— Cause an element to disappear slowly;
$('selector').each();
(P194)
$('selector').each(function() { ...... }); —— jQuery's each() function lets you loop through a selection of page elements add perform a series of tasks on each element;
(P195)
$(this) —— You'll use the $(this) keyword almost every time you use the each();
(P201) Javascrip is an event-driven language;
(P203) Mouse Events —— click、dblclick、mousedown、mouseup、mouseover、mouseout、mousemove;
(P204) Document/Window Events —— load (the load event fires when the Web Browser finishes downloading all of a web page's files)、resize、scroll、unload;
(P205) Form Events —— submit、reset、change、focus、blur (the blue event is the opposite of focus. It's triggered when you exit a currently focused field.);
(P206) Keyboard Events —— keypresss()、keydown()、keyup();
(P207)
Event handler names are created by simply adding the word on to the beginning of the event;
You can think of "on" as "when";
(P211) When you assign a function to an event, you omit the () that you normally add to the end of a function's name to call it;
(P213) $('a').mouseover(function() { ...... });
(P218) $(document).ready(function() { ...... });
(P220) $('#selector').hover(function1, function2);
(P221) $('#selector').toggle(function1, function2); —— It responds to clicks;
(P223) eventobject.preventDefault();
(P224) $('#selector').unbind('event');
(P226)
$('#selector').bind('click', myData, functionName);
$('#selector').bind('click', functionName) = $('#selector').click(functionName);
(P230) .next() —— finds the tag immediately following the current tag;
(P243) jQuery's user Interface library includes an official set of add-on effects. It builds on jQuery's basic features and offers more eye-catching effects;
(P243) Basic showing and Hinding —— show()、hide()、toggle();
(P244)
Fading Elements In and Out —— fadeIn()、fadeOut()、fadeTo();
fadeTo() —— must supply a speed value; must supply a second value from 0 to 1);
If you fade an selement to 0 opacity, the element is no longer visible, but the sapce it accupied on the page remains;
(P245) Sliding Events —— SlideDown()、SlideUp()、SlideToggle();
(P246) The Callback function is passed as the second argument to most effects;
(P246) .animate() —— lets you animate any CSS property;
(P247) In order to animate a position of an element using the CSS left, right, top or bottom properties, you must set that elemetns CSS position to either absolute or relative. Those are the only two positioning properties that let you assign positioning values to them;
(P259) www.ajaxload.info;
(P281) createing new windows —— open(URL, name, properties);
(P282) Don't include any spaces in the string defining the new window's properties;
(P283) Firefox and Internet Explorer normally don't let you hide the status bar, so it's always visible in the browsers;
(P284) window object methods —— close()、blur()、focus()、moveBy()、moveTo()、resizeBy()、resizeTo()、scrollBy()、scrollTo();
(P299) $('#selector').find('tagName') —— search for another element include the current element;
(P300) The CSS "cursor" property lets you assign the type of cursor the browser uses when the mouse is over a particular element;
(P306) $('#selector tagName: has (tarName)'); —— Let's you select tags that contain another specific tag inside them;
(P309) text fields, password fields, radio buttons, checkboxes and submit buttons all share the <input> tag, and you specify which one with the type attribute.
(P312) jQuery includes lots of selectors to make it easy to work with specific types of form fields —— :input、:text、:password、:radio、:checkbox、:submit、:image、:reset、:botton、:file、:hidden;
(P313) jQuery provides a few very useful filters that find form fields matching a prticular state —— :checked、:selected;
(P314) $('selector').val() —— Both set and read the value of a form field;
(P315) Form Events —— submit()、focus()、blur()、click()、change();
(P380) This method is particular good if you want to dynamically generage tooltips from a datatbase or a server-side program. You don't have to point to a real web pages. You can point to a dynamic page;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架