jQuery日本語リファレンス

jQuery does not mean Japanese Query...

Internals/API/jQuery - Sample Code

jQuery.data(elem, name, value)


            
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="/jquery/js/jquery.js"></script>
  
  <script>
  $(document).ready(function(){
    
    var adiv = $("div").get(0);
    jQuery.data(adiv, "test", { first: 16, last: "pizza!" });
    $("span:first").text(jQuery.data(adiv, "test").first);
    $("span:last").text(jQuery.data(adiv, "test").last);

  });
  </script>
  <style>
  div { color:blue; }
  span { color:red; }
  </style>
</head>
<body>
  <div>
    The values stored were 
    <span></span>
    and
    <span></span>
  </div>
</body>
</html>
            
          
[実行結果]
[jQuery.data(elem, name, value) の説明へ]