prihlasenyprihlasit | registrovat

.data()

kategorie: Data

.data(key) vráti: objekt

Vráti hodnotu nazývanú úložisko dát pre element, ako je stanovené na základe data(key, value).

alert($('body').data('foo'));
alert($('body').data());

alert( $("body").data("foo")); //undefined
$("body").data("bar", "foobar");
alert( $("body").data("foobar")); //foobar

HTML 5 data- Atribúty

Od jQuery 1.4.3 HTML 5 data- atribúty budú automaticky pridané do jQuery data objektu. Zaobchádzanie s atribútmi vloženými cez pomlčky bolo v jQuery 1.6 zmenené vzhľadom ku W3C HTML5 špecifikácii.

Napríklad podaním následujúceho HTML:

.data(name, value) vráti: jQuery

Uchova hodnotu v nazyvanom mieste.

If the jQuery collection references multiple elements, the data element is set on all of them. A data value that is a Javascript object is not copied and will be shared across all elements in the collection.

This function can be useful for attaching data to elements without having to create a new expando. It also isn't limited to a string. The value can be any format.

It may also be used for getting events attached to elements, however this is unsupported. First paramater being the element, second being the string "events"

API

© 2009 Shaddow admin hosting od VIPHosting