This code best demonstrates my confusion.
var nativeObj, jWrapped, jSelector;
nativeObj = $( '#tableTab' ) [0];
jWrapped = $( nativeObj );
jSelector = $( '#tableTab' );
$.data( jWrapped, 'key', { test: 12 } );
$.data( $( '#tableTab' ) [0], 'key', { test: 34 } );
$.data( $( '#tableTab' ) , 'key', { test: 56 } );
console.log( $.data ( jWrapped ) );
console.log( $.data ( jWrapped[0] ) );
console.log( $.data ( nativeObj ) );
console.log( $.data ( $( nativeObj ), 'test' ) );
console.log( $.data ( $( '#tableTab' ) [0] ) );
console.log( $.data ( $( '#tableTab' ) , 'test' ) );
Whoa, wait, what's going on ?
1. Why do I get different results? I used only 1 selector and refer to one element.
2. Why are they not an object reference jWrapped, but does an object from $( '#tableTab' )create the same result?
3. In addition, jWrappedand jWrapped[0]produce different results? The first object is jQuery wrapped, and the second is a native DOM object. Essentially, they refer to the same element with a different result ! ??
console.log( $( '#tableTab' ) [0]);
console.log( nativeObj );
console.log( $( nativeObj ) );
console.log( jWrapped );
console.log( $( '#tableTab' ) );
console.log( jSelector );
Ok nativeObj == $( '#tableTab' ) [0]what i expected
Wow, that was weird, why not jWrapped == $( nativeObj )?
, jSelector = $( '#tableTab' ), ,
, , $.data DOM-,
$( '#tableTab' ).data( 'key' , { test: 78 } );
console.log($( '#tableTab' ).data('key'));
, , ... .
, , jQuery, Javascript, IE...
, IE, . jQuery ? , IE ...
, , $.data jQuery ,
, , . ?
.
jQuery.data()?, , , , . , , jQuery.