jQuery_Succinctly.pdf
(
936 KB
)
Pobierz
By
Cody Lindley
Foreword by Daniel Jebaraj
2
Copyright © 2012 by Syncfusion Inc.
2501 Aerial Center Parkway
Suite 200
Morrisville, NC 27560
USA
All rights reserved.
I
mportant licensing information. Please read.
This book is available for free download from
www.syncfusion.com
on completion of a registration form.
If you obtained this book from any other source, please register and download a free copy from
www.syncfusion.com
.
This book is licensed for reading only if obtained from
www.syncfusion.com
.
This book is licensed strictly for personal, educational use.
Redistribution in any form is prohibited.
The authors and copyright holders provide absolutely no warranty for any information provided.
The authors and copyright holders shall not be liable for any claim, damages, or any other liability arising from, out
of, or in connection with the information in this book.
Please do not use this book if the listed terms are unacceptable.
Use shall constitute acceptance of the terms listed.
E
dited by
This publication was edited by the Syncfusion ASP.NET MVC Team, who provide advanced ASP.NET MVC
frameworks for business applications to help you deliver innovation with ease. Check out samples online at
http://mvc.syncfusion.com/sfmvctoolssamplebrowser
.
3
Table of Contents
The Story behind the
Succinctly
Series of Books ...................................................................8
About the Author ......................................................................................................................10
Introduction ...............................................................................................................................11
Preface .......................................................................................................................................12
jQuery semantics .....................................................................................................................12
How the book is structured ......................................................................................................12
More code, less words.............................................................................................................12
Why oh why did I use
alert()
for code examples? ...............................................................12
Color coding.............................................................................................................................13
Completely grok jQuery
text()
before reading this book.......................................................13
Code examples........................................................................................................................14
Chapter 1
Core jQuery ..........................................................................................................15
Base concept behind jQuery....................................................................................................15
The concept, behind the concept, behind jQuery ....................................................................16
jQuery requires HTML to run in standards mode or almost-standards mode..........................16
Waiting on the DOM to be ready .............................................................................................17
Executing jQuery code when the browser window is completely loaded.................................17
Include all CSS files before including jQuery...........................................................................18
Using a hosted version of jQuery.............................................................................................18
Executing jQuery code when DOM is parsed without using
ready()
.....................................19
Grokking jQuery chaining ........................................................................................................20
Breaking the chain with destructive methods ..........................................................................21
Using destructive jQuery methods and exiting destruction using
end()
.................................21
Aspects of the jQuery function.................................................................................................22
Grokking when the keyword
this
refers to DOM elements ....................................................23
Extracting elements from a wrapper set, using them directly without jQuery ..........................25
Checking to see if the wrapper set is empty ............................................................................27
Creating an alias by renaming the jQuery object itself ............................................................28
Using
.each()
when implicit iteration is not enough...............................................................28
Elements in jQuery wrapper set returned in document order ..................................................31
Determining context used by the jQuery function ....................................................................31
Creating entire DOM structure, including DOM events, in a single chain................................32
Chapter 2
Selecting ..............................................................................................................34
Custom jQuery filters can select elements when used alone ..................................................34
Grokking the
:hidden
and
:visible
filter ..............................................................................34
4
Using the
is()
method to return a Boolean value ..................................................................35
You can pass jQuery more than one selector expression .......................................................36
Checking wrapper set
.length
to determine selection ..........................................................36
Creating custom filters for selecting elements .........................................................................37
Differences between filtering by numeric order vs. DOM relationships ...................................38
Selecting elements by
id
when the value contains meta-characters ......................................41
Stacking selector filters............................................................................................................42
Nesting selector filters .............................................................................................................43
Grokking the
:nth-child()
filter ............................................................................................44
Selecting elements by searching attribute values using regular expressions..........................45
Difference between selecting direct children vs. all descendants............................................46
Selecting direct child elements when a context is already set.................................................46
Chapter 3
Traversing ............................................................................................................48
Difference between
find()
and
filter()
methods ..............................................................48
Passing
filter()
a function instead of an expression...........................................................49
Traversing up the DOM ...........................................................................................................51
Traversing methods accept CSS expressions as optional arguments ....................................52
Chapter 4
Manipulation ........................................................................................................53
Creating, operating, and adding HTML on the fly ....................................................................53
Grokking the
index()
method.................................................................................................54
Grokking the
text()
method ..................................................................................................56
Update or remove characters using a regular expression .......................................................56
Grokking the
.contents()
method.........................................................................................57
Using
remove()
does not remove elements from wrapper set ...............................................58
Chapter 5
HTML Forms ........................................................................................................59
Disable/enable form elements .................................................................................................59
How to determine if a form element is disabled or enabled.....................................................60
Selecting/clearing a single check box or radio button..............................................................60
Selecting/clearing multiple check boxes or radio button inputs ...............................................61
Determining if a check box or radio button is selected or cleared ...........................................62
How to determine if a form element is hidden .........................................................................62
Setting/getting the value of an input element...........................................................................63
Setting/getting the selected option of a select element ...........................................................64
Setting/getting selected options of a multi-select element.......................................................64
Setting/getting text contained within a
<textarea>
................................................................65
Setting/getting the value attribute of a button element ............................................................66
Editing select elements............................................................................................................66
5
Plik z chomika:
Firstone
Inne pliki z tego folderu:
pro_jquery_mobile.pdf
(25613 KB)
professional_jquery.pdf
(24031 KB)
pro_sharepoint_with_jquery.pdf
(23661 KB)
Missing Manual - JavaScript&JQuery.pdf
(15612 KB)
Extending jQuery.pdf
(16242 KB)
Inne foldery tego chomika:
Beighley Lynn - SQL. Rusz głową!
HTML5(1)
JavaScript
Javascript - Building Web Apps
Wordpress
Zgłoś jeśli
naruszono regulamin