JS Basics
alert ();
Confirm ();
Basic syntax: Consistent with C #
Data types and type conversions
var (string,decimal)
parseint ()
Parsefloat ();
IsNaN ();
Operator:
Math operators: +-*/+--%
Relational operators: = = = = >= <= > <
Logical operator:&& | | !
Other operators: + = = *=/=?:
Statement
Branching statements, looping statements
Arrays: Array ();
Functions: function
Funciton function name (a)
{
Return??;
}
DOM Operations
var a =document.getelementbyid ();
var b =document.getelementsbyclassname ();
Document.getelementsbyname ();
document.getElementsByTagName ();
window.open (', ' _blank ');
Window.close ();
Window.opener-Returns a Window object
Window.setinterval (function () {},2000);
Window.settimeout (Funciton () {},2000);
Window.clearinterval ();
Window.scrollto (x, y);
Window.history.go (-1);
window.location.href= "url"; -Current Page Jump
var a = window.location.href; -Get the current page address
Style of manipulating elements
A.style.backgroundcolor = "Red";
A.style.width= "10px";
A.offsettop/left/width/height-Real-time data
Manipulating the contents of an element
Table cell Element-value
Non-table cell element-InnerHTML InnerText
Properties of the Action element
SetAttribute ("', '");
GetAttribute (");
RemoveAttribute (");
Creating and deleting elements
object. Innerhtml= "Mark the string that is spelled well";
-----------------
var a = document.createelement (' div ');
A.setattribute (' class ', ' div2 ');
document.getElementById (' Div1 '). appendchild (a);
-----------------
Object. Parentnode.removechild (object);
Get related elements
Get Object Parent
Object. parentnode
Get Object Children
Object. childNodes
Get brother
Object. previoussibling-NOTE!!!
Or take my brother.
Object. nextsibling-!!
String manipulation Math operations
Time and date
OnClick
Onmouseover/onmouseout
Onfocus/onblur
OnKeyUp
OnDblClick
jquery Basics
What is jquery?
JS-based framework.
ID Selector: #
Class selector:.
Tag Selector: Label name
To use, separate, or tie
Descendants: separated by a space;
Filter
Take the first-:
Take End-: Last
Equals
: EQ (Index)
Not equal to
Greater than-: GT (Index)
Less than-: LT (index)
Exclude-: Not (selector)
Odd even
Odd-: Odd
Even-: even
Attribute filtering
Property name filtering-Directly plus [property name]
Content filtering
Text-: Contains ("string")
Child element-: Has ("selector")
Event
General Events
Future element notation-$ (document). On (' event name ', ' element name ', function () {});
Block event bubbling-return False
DOM Operations
Action Properties
Gets the property-var s = $ ("selector"). attr ("attribute name")
Set Properties-$ ("selector"). attr ("Property name", "Property value")
Delete Property-$ ("selector"). Removeattr ("attribute name")
Action Style
Working with inline styles
Get style-var s = $ ("selector"). CSS ("style name")
Set style-$ ("picker"). CSS ("style name", "value")
Manipulating the style sheet's class
Add Class-$ ("selector"). AddClass ("Class name")
Move out of Class-$ ("selector"). Removeclass ("Class name")
Add alternating class-$ ("selector"). Toggleclass ("Class name")
Action Content
Form elements
Value-var s = $ ("selector"). Val ()
Assignment-$ ("selector"). Val ("value")
Non-form elements
Assignment-$ ("selector"). HTML ("Content"), $ ("selector"). Text ("Content")
Value-var s = $ ("selector"). html (), var s = $ ("selector"). Text ()
Manipulating related elements
Find
Father, predecessor.
Parent ()-Father
Parents (selector)-Seniors
Child. Descendants
Children (selector)-Child
Find (selector)-descendants
Brother
Brother
Prev ()-One of the preceding elements
Prevall (selector)-Elements of the front sibling
Brother
Next ()-an element that follows
Nextall (selector)-elements behind the sibling level
New-$ ("HTML string")
Add to
Appen (Jqurey object)-Internal add
After ()-lower lateral add
Before-Upper lateral add
Removed from
Empty ()-Clears all elements inside
Remove ()-remove element
Copy-Clone ()
December 24, 2017 JS and jquery basics