Ken’s JavaScript, jQuery Notes

[Pages:20]20July12

Ken's Javascript, jQuery Notes

1

Ken's JavaScript, jQuery Notes

Quick refresher thru code snippets

Contents

Html .................................................................................................................................... 3 Setting HTML Form Fields via Javascript...................................................................... 3

Updating the Forms Webpage when Returning from Server.............................................. 3 A server side return wont trigger client side includes in IE8:......................................... 4 This client side scripting won't cause the page to refetch its includes (in IE8) either ... 4 What will work is returning to a specific URL from the server ..................................... 4

CSS Selectors...................................................................................................................... 5 Defining .......................................................................................................................... 5 File .............................................................................................................................. 5 Inline ........................................................................................................................... 5 Selectors .......................................................................................................................... 5 Combining Selectors ................................................................................................... 5 Comma mean OR............................................................................................................ 5 Using ............................................................................................................................... 5 Pseudo Class ................................................................................................................... 6 You don't define these, they're just there ................................................................... 6 Selector Precidence ......................................................................................................... 6 The more specific the selector, the more precidence .................................................. 6 Color ............................................................................................................................... 6

JavaScript / jQuery.............................................................................................................. 7 Script Inclusion ............................................................................................................... 7 Data Types ...................................................................................................................... 7 Arrays.............................................................................................................................. 7 Structures (or sort of structures) ..................................................................................... 8 Addressing .................................................................................................................. 8 Variable Substitution (for the Key definition) ............................................................ 8 Object Intialization...................................................................................................... 8 String............................................................................................................................... 9 Strict Equality, Inequality ............................................................................................... 9 Collections ...................................................................................................................... 9 Functions....................................................................................................................... 10 // some code .................................................................................................................. 10 Calling a JavaScript function .................................................................................... 11 Returning................................................................................................................... 11 Handling Errors............................................................................................................. 11 ready function ............................................................................................................... 12 /* define another callback function here */............................................................... 12 ....................................................................................................... 12 jQuery Object................................................................................................................ 12 Noscript......................................................................................................................... 13



20July12

Ken's Javascript, jQuery Notes

2

User Interaction............................................................................................................. 13 Redirect ......................................................................................................................... 13

Php Html version of redirect ..................................................................................... 13 Getting the Link Clicked on.......................................................................................... 13 OnClick ......................................................................................................................... 14

To a url ...................................................................................................................... 14 Math .............................................................................................................................. 14 Older Browser Trick ..................................................................................................... 14 Strings ........................................................................................................................... 14

Trim, Length ............................................................................................................. 14 Popups........................................................................................................................... 15

Confirmation ............................................................................................................. 15 Event Handlers.............................................................................................................. 15

Keyboard events........................................................................................................ 16 Checking Form Info with Javascript............................................................................. 16

Alternative (without global onsubmit handler)......................................................... 16 DOM ............................................................................................................................. 17 Common DOM calls for form validation...................................................................... 17 Table object properties.................................................................................................. 17 Date/Time ..................................................................................................................... 20



20July12

Ken's Javascript, jQuery Notes

3

Html

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download