Terminology
$.ajax(<url>,<settings>) ¶ Perform an asynchronous HTTP (Ajax) request to <url>.
$._data(<element>,"events") ¶ Return the object of events that are attached to a particular element.
$(<function>) ¶ Binds a function to be executed when the DOM has finished loading.
$(<html>) ¶ Creates DOM elements on the fly from the provided string of raw HTML.
$.parseJSON(<string>) ¶ Convert a JSON string into a JavaScript variable.
$.post(<url>,<data>,<callback>,<dataType>) ¶ Load data from the server using a HTTP POST request.
<elementName>.<className> ¶ Select an <elementName> element with class <className>.
<elementName>#<id> ¶ Select the <elementName> element with ID <id>.
<elementSelector> ¶ A function call of the form $(<string>), or the value returned by such a call.
<elementSelector>.attr("disabled", true) ¶ Disable one or more elements.
<elementSelector>.data() ¶ Return all of the data values ("data-<key>" attributes) for the selected element(s).
<elementSelector>.data(<key>) ¶ Retrieve the value of the "data-<key>" attribute for the selected element(s).
<elementSelector>.data(<key>,<value>) ¶ Store <value> in the element's "data-<key>" attribute.
<elementSelector>.load(<url>,<data>,<callback>) ¶ Load data from the location specified by <url>, passing optional <data> as parameters, and place the returned HTML into the matched element(s). Once done, execute optional <callback>.
<elementSelector>.off() ¶ Remove all event handlers that were added to the selected elements.
<elementSelector>.on("click", function (e) { <statements> }) ¶ Create a click event for one or more elements.
<elementSelector>.one(<events>,<selector>,<data>,<callbackFunction>) ¶ Attach a handler to one or more events for the selected elements. The handler is executed at most once per element per event type.
<elementSelector>.submit(<handler>) ¶ Bind an event handler to the "submit" JavaScript event.
Facts, Thoughts and Opinions
A Generic Check-All Function with jQuery
function checkAll() { $(":checkbox").each(function () { $(this).attr('checked', true); }); } function unCheckAll() { $(":checkbox").each(function () { $(this).attr('checked', false); }); }
Count total items in a DropDownList using jQuery
var count = $("#DropDownList1 option").length;
DropDownList selecteditem text using jQuery
$("#ddl option:selected").text()
Using $.extend() to "clone" a non-DOM object
// Define a first object and then use $.extend to create a merged object with a, b, and c
var ob1 = {a: 'hi', b: 'there'}
var ob2 = $.extend(ob1, {c: '!'});
// Modify ob2, but since the property doesn't exist except for ob1's prototype, it directly modifies ob1
ob2.a = 'There';
console.log(ob1);
----------------------------------------------------------------------------------------
// In order to "really" clone the non-DOM object, we need to do this
// Note the extra $.extend({}, ob1) that uses a blank object literal as the basis for the object
var ob1 = {a: 'hi', b: 'there'}
var ob2 = $.extend($.extend({}, ob1), {c: '!'});
ob2.a = 'There';
console.log(ob1);
Images
- Subtopics
Sources & Bookmarks