はdocument.ready
にwindow.load
にいくつかのデータを格納および取得する必要があります:window.loadとdocument.readyのjQuery data()は未定義ですか?
<script>
$(window).load(function() { // Store here
$('img.storable').each(function() {
$(this).data("key", "value");
console.log($(this).data("key")); // Output: value
};
};
$(document).ready(function() { // Retrieve here
$('img.storable').each(function() {
console.log($(this).data("key")); // Output: undefined!
};
};
</script>
出力document.ready
には未定義です。私はdomイベントについて何か気付かないのですか?