需要一些数据存储在window.load
和检索document.ready
:在window.load和document.ready中的jQuery数据(),有没有定义?
<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事件的一些事情?