diff --git a/entries/contents.xml b/entries/contents.xml index d10defc0..9f4d8b2f 100644 --- a/entries/contents.xml +++ b/entries/contents.xml @@ -33,7 +33,7 @@ $( ".container" ) .filter( "br" ) .remove(); -
This code first retrieves the contents of <div class="container">
and then filters it for text nodes, which are wrapped in paragraph tags. This is accomplished by testing the .nodeType
property of the element. This DOM property holds a numeric code indicating the node's type; text nodes use the code 3. The contents are again filtered, this time for <br />
elements, and these elements are removed.
This code first retrieves the contents of <div class="container">
and then filters it for text nodes, which are wrapped in paragraph tags. This is accomplished by testing the .nodeType
property of the element. This DOM property holds a numeric code indicating the node's type; text nodes use the code 3. The contents are again filtered, this time for <br />
elements, and these elements are removed.
When this statement is executed, the element slides up for 300 milliseconds and then pauses for 800 milliseconds before fading in for 400 milliseconds.
- The .delay()
method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay()
is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.
+ The .delay()
method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay()
is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.
Given a document with six paragraphs, this example will set the HTML of <div class="demo-container">
to <p>All new content for <em>6 paragraphs!</em></p>
.
This method uses the browser's innerHTML
property. Some browsers may not generate a DOM that exactly replicates the HTML source provided. For example, Internet Explorer prior to version 8 will convert all href
properties on links to absolute URLs, and Internet Explorer prior to version 9 will not correctly handle HTML5 elements without the addition of a separate compatibility layer.
To set the content of a <script>
element, which does not contain HTML, use the .text()
method and not .html()
.
To set the content of a <script>
element, which does not contain HTML, use the .text()
method and not .html()
.
Note: In Internet Explorer up to and including version 9, setting the text content of an HTML element may corrupt the text nodes of its children that are being removed from the document as a result of the operation. If you are keeping references to these DOM elements and need them to be unchanged, use .empty().html( string )
instead of .html(string)
so that the elements are removed from the document before the new string is assigned to the element.
For id selectors, jQuery uses the JavaScript function document.getElementById()
, which is extremely efficient. When another selector is attached to the id selector, such as h2#pageTitle
, jQuery performs an additional check before identifying the element as a match.
Calling jQuery()
(or $()
) with an id selector as its argument will return a jQuery object containing a collection of either zero or one DOM element.
Each id
value must be used only once within a document. If more than one element has been assigned the same ID, queries that use that ID will only select the first matched element in the DOM. This behavior should not be relied on, however; a document with more than one element using the same ID is invalid.
If the id contains characters like periods or colons you have to escape those characters with backslashes.
+If the id contains characters like periods or colons you have to escape those characters with backslashes.
cache
option is set to true
. Note: This will turn POSTs into GETs for remote-domain requests. null
or {}
instead. (See json.org for more information on proper JSON formatting.)cache
option is set to true
.cache
option is set to true
. Note: This will turn POSTs into GETs for remote-domain requests. null
or {}
instead. (See json.org for more information on proper JSON formatting.)cache
option is set to true
.In particular, note that the 0-based indexing means that, counter-intuitively, :odd
selects the second element, fourth element, and so on within the matched set.
.triggerHandler( eventType )
executes all handlers bound with jQuery for the event type. It will also execute any method called on{eventType}()
found on the element. The behavior of this method is similar to .trigger()
, with the following exceptions:
.triggerHandler( eventType )
executes all handlers bound with jQuery for the event type. It will also execute any method called on{eventType}()
found on the element. The behavior of this method is similar to .trigger()
, with the following exceptions:
.triggerHandler( "event" )
method will not call .event()
on the element it is triggered on. This means .triggerHandler( "submit" )
on a form will not call .submit()
on the form..trigger()
will operate on all elements matched by the jQuery object, .triggerHandler()
only affects the first matched element.The .val()
method is primarily used to get the values of form elements such as input
, select
and textarea
. In the case of select
elements, it returns null
when no option is selected and an array containing the value of each selected option when there is at least one and it is possible to select more because the multiple
attribute is present.
For selects and checkboxes, you can also use the :selected and :checked selectors to get at values, for example:
+For selects and checkboxes, you can also use the :selected and :checked selectors to get at values, for example:
// Get the value from a dropdown select
$( "select.foo option:selected").val();
diff --git a/pages/Types.html b/pages/Types.html
index cd66dd4d..422f6bd6 100644
--- a/pages/Types.html
+++ b/pages/Types.html
@@ -11,7 +11,7 @@
JavaScript provides several built-in datatypes. In addition to those, this page documents virtual types like Selectors, enhanced pseudo-types like Events and all and everything you wanted to know about Functions.
-You should be able to try out most of the examples below by just copying them to your browser's JavaScript Console (Chrome, Safari with Develop menu activated, IE 8+) or Firebug console (Firefox).
+
You should be able to try out most of the examples below by just copying them to your browser's JavaScript Console (Chrome, Safari with Develop menu activated, IE 8+) or Firebug console (Firefox).
Whenever an example mentions that a type defaults to a boolean value, the result is good to know when using that type in a boolean context:
@@ -296,7 +296,7 @@ Iteration
alert( "key is " + [ key ] + ", value is " + obj[ key ] );
}
-Note that for-in-loop can be spoiled by extending Object.prototype (see Object.prototype is verboten) so take care when using other libraries. +
Note that for-in-loop can be spoiled by extending Object.prototype (see Object.prototype is verboten) so take care when using other libraries.
jQuery provides a generic each function to iterate over properties of objects, as well as elements of arrays:
@@ -412,7 +412,7 @@This indicates that the method doesn't only expect an array as the argument, but also specifies the expected type. The notation is borrowed from Java 5's generics notation (or C++ templates).
The PlainObject type is a JavaScript object containing zero or more key-value pairs. The plain object is, in other words, an Object
object. It is designated "plain" in jQuery documentation to distinguish it from other kinds of JavaScript objects: for example, null
, user-defined arrays, and host objects such as document
, all of which have a typeof
value of "object." The jQuery.isPlainObject()
method identifies whether the passed argument is a plain object or not, as demonstrated below:
+
The PlainObject type is a JavaScript object containing zero or more key-value pairs. The plain object is, in other words, an Object
object. It is designated "plain" in jQuery documentation to distinguish it from other kinds of JavaScript objects: for example, null
, user-defined arrays, and host objects such as document
, all of which have a typeof
value of "object." The jQuery.isPlainObject()
method identifies whether the passed argument is a plain object or not, as demonstrated below:
var a = [];
@@ -621,7 +621,7 @@ XMLHttpRequest
- W3C standard
- Apple (Safari)
-
- Mozilla (Firefox)
+
- Mozilla (Firefox)
- Microsoft (Internet Explorer)
- Opera
@@ -641,4 +641,4 @@ Callbacks Object
XML Document
A document object created by the browser's XML DOM parser, usually from a string representing XML. XML documents have different semantics than HTML documents, but most of the traversing and manipulation methods provided by jQuery will work with them.
Assert
-A reference to or instance of the object holding all of QUnit's assertions. See the API documentation for QUnit.assert
for details.
+A reference to or instance of the object holding all of QUnit's assertions. See the API documentation for QUnit.assert
for details.