yuheijotaki.com

jQuery.data()

jQuery.data()の基本的な使い方メモ

 

<div class="hoge" data-sample="content">jQuery.data()</div>
<script>
$('.hoge').attr('data-sample'); //data-sampleの値取得
$('.hoge').attr('data-sample','contentChanged'); //contentChangedに書き換え
</script>
[data-sample] {
	color: #999;
}
[data-sample="contentChanged"] {
	color: #333;
}