İşte davranışı göstermek için basit bir örnek:
bu html biçimlendirme Verilen:
<div data-company="Microsoft"></div>
ve (jQuery 1.5.1 kullanarak) bu jQuery kodu:
// read the data
alert($("div").data("company"));
// returns Microsoft <<< OK!
// set the data
$("div").data("company","Apple");
alert($("div").data("company"));
// returns Apple <<< OK!
// attribute selector
alert($("div[data-company='Apple']").length);
// returns 0 <<< WHY???
// attribute selector again
alert($("div[data-company='Microsoft']").length);
// returns 1 <<< WHY???
// set the attribute directly
$("div").attr("data-company","Apple");
alert($("div[data-company='Apple']").length);
// now returns 1 <<< OK!
jQuery otomatik ithalat yana HTML5 verileri jQuery'nin veri nesnesine *, veriler değiştiğinde özelliklerin güncellenmemesi gerekir mi?
@James '" div [data-company = 'Apple' ''' ile kapatmayı unutmuşsunuzdur] –