1

Seems like certain browsers (Internet Explorer with Compatibility View ON) don't support the .data() object, whats the next best thing to use?

$("#object").data('value','hi');

I was thinking I could apply classes to the object and use hasClass() but maybe there's a better way? Would be better if it was as lightweight as possible (without using cookies)

4

2 に答える 2

2

そのモードでもかなり確実data()に動作します。

そうでない場合は、正しいメタ タグを に追加して、<head>IE が壊れたモードを使用しないようにします。

于 2012-12-31T15:25:49.660 に答える
1

html5 データ属性を使用できます。

$("#object").attr('data-val1','hi');
于 2012-12-31T15:28:10.483 に答える