0% found this document useful (0 votes)
2 views

Javascript Programing

2nd ed.) [Easttom

Uploaded by

mujahed22.mb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Javascript Programing

2nd ed.) [Easttom

Uploaded by

mujahed22.mb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Data Types string

boolean
number
Types Non-Data Types undefined
null onclick (click)
ondblclick (double click)
Array oncontextment (right click)
$("selector").html - replaces html Object
$("selector").text - replaces w/ esc text Object Types Function Mouse Events onmouseenter (pointer enters element)
onmouseleave (pointer leaves element)

$("selector").append("newContent") - inside tag, at end Array Method List onmousedown (click press)
$("selector").prepend("newContent") - inside tag, at
front Date Method List, Format onmouseup (click release)

$("tagName") Built-In Objects String Method List onmousemove (pointer movement)


Content Manipulation
$("selector").before("<p>htmlContent</p>") - before tag Reg Expression onmouseout
$("#identifier")
$("selector").after("<p>htmlContent</p"> - after tag Math Method List
$(".className")
Number Method List
$("selector").wrap("<div style='color:red'/>") - wrap selector
Core Javascript onkeydown (press)
$("tag.className") Selectors Random Method List Keyboard Events
$(".tag#id.className") $("selector").wrapAll("<div style='color:red'/>") - wrap selectors onkeypress (keydown for character/numbers)
$("*") with common parent
IF if (x) {...} onkeyup (release)

$("div > p") - p is direct child if (x) {...} else if (y) {...}
$("selector").empty() - removes content
$("div p") - p has any parent div $("selector").remove() - remove w/ its event handlers FOR for (var i=0; i< x.length; i++) {...}

$("ul + div") - div right after ul $("selector").replaceAll("content") - replaces w/ content for ([item] in [array]) {...}
Logic Loops onblur
$("selector").replaceWith("content") - see above, while (x) {...} onchange
content can be a callback function
do {...} while (x) onfocus
WHILE
:first, :last onfocusin
:even, :odd onfocusout
Form Events
$("a").attr("target", "_blank") - add attribute, open in new tab oninput
:not(expression) getElementByID
Attribute Manipulation Find Element oninvalid
:contains('text') $("img").attr({ src: "image.jpg", title:"IMAGE"}) - add attrib using object getElementsByTagName onreset
:gt(), :lt(), eq() - greater than, less than, equal Selector Filters
$("a").removeAttr("href") - removes links getElementsByClassName onsearch
:focus onselect
.style.[property] = "new style"
:animated - in process of being animated Element Attributes onsubmit
.innerHTML = "content"

:parent - is a parent $("selector").hasClass("name") .setAttribute("attribute", "value")

:first-child Class Manipulation $("selector").addClass("name") Add Event Listener


:nth-child(4) or nth-child(2n) element.addEventListener("event", function);
$("selector").removeClass("name") ondrag
:last-of-type element.onclick(x) **don't use
$("selector").toggleClass("name") ondragend

Drag Events ondragenter


DOM Events Full List
ondragleave
ondragover
ondragstart
$("selector").on(events [, selector filter][,data], handlerFn)
Main Method
$("selector").off( events [, selector filter ] [, handler ] ) Javascript Programming ondrop

JQuery ($) Document Object


(Web Browser JS)
stopPropagation()
.blur( [eventData ], handler ) Methods
preverntDefault()
$("selector").show(optionalTime, optionalEffect);
.change( [eventData ], handler ) DOM Event Objects stopImmediatePropagation()
$("selector").hide(optTime, optEffect); Properties
.focus( [eventData ], handler ) $("selector").toggle("slow", completionFn); Methods
Form Events (shortcuts) onLoad()
.focusin( [eventData ], handler ) Prototypes Document Object Method
$("selector").fadeIn(optTime) Working with Objects
$("selector").fadeIn(optTime) Constructors
.focusout( [eventData ], handler )
Animation Effects $("selector").fadeTo(optTime, optOpacity, button
Prototypical Inheritance
.select( [eventData ], handler ) completionFn) buttons
that=this which (which button pressed)
.submit( [eventData ], handler ) $("selector").slideUp(optTime, effect, completionFn)
Scope/NameSpace detail (# clicks)
$("selector").slideDown(optTime, effect, completionFn)
$("selector").slideToggle(optTime, effect, completionFn)
First-Class Citizens relatedTarget
.click( [eventData ], handler )
Events $("selector").animate() - custom animation Declaration vs. Expression
.contextmenu( [eventData ], handler ) altKey
Working with Functions Closures
.dblclick( [eventData ], handler ) ctrlKey
Immediately Invoked Function Expression (IIFE)
.hover( handlerIn, handlerOut )
Intermediate Currying
Mouse Object Properties
metaKey

.mousedown( [eventData ], handler )


$(document).ajaxComplete( handler ) Javascript Callbacks
shiftKey

.mouseup( [eventData ], handler ) $(document).ajaxError( handler )


Error Object
$(document).ajaxSend( handler ) clientX
Mouse Events (shortcuts)
.mousemove( [eventData ], handler ) JSON Object: parse(), stringify() clientY
$(document).ajaxStart( handler )
Map / Weak Map Objects (key-value pairs)
$(document).ajaxStop( handler ) Set / Weak Set Objects (set of unique values) pageX
.mouseenter( [eventData ], handler )
pageY
Common Built-In Objects Promise Object: (resolve, reject)=>{}.then().catch().
.mouseover( [eventData ], handler ) $(document).ajaxSuccess( handler )

.mouseleave( [eventData ], handler ) Type Declaration Generator Object: next(),return(), throw() screenX
.mouseout( [eventData ], handler ) AJAX Function Object: apply(), call(), bind() screenY
[object].serialize() -prepare form data let vs. var
[object].serializeArray() -prepare form data Regular Expressions (RegEx)
.toggle( handler, handler [, handler ] ) String Literals (back-tick) key
keyCode
for..of loop (vs. for..in loop, or values vs keys)
charCode
$.ajax( url [, settings ] ) - basic method, shortcuts below
Interfaces (Type Schema)
altKey
.keypress( [eventData ], handler ) Classes (object constructor)
ctrlKey
.keyup( [eventData ], handler )
$.get( url [, data ] [, success ] [, dataType ] ) Advance Javascript Function Decorators
Keyboard Object Properties metaKey
.keydown( [eventData ], handler ) Keyboard Events (shortcuts) $.getJSON( url [, data ] [, success ] ) Features (ES6/TS) Arrow Functions (x => {}) shiftKey
$.getScript( url [, success ] ) Default Parameters (functions)
location
$.post( url [, data ] [, success ] [, dataType ] ) which
Modules (export/import external modules)
$.load( url [, data ] [, complete ] )
Namespaces (internal modules)

Generics

JQuery
External Modules
RxJS: Reactive Javascript

Extending Javascript Lodash: Array Manipulation


with Libraries

You might also like