jQuery

???; ???; ?? ???? ??? ???;

jquery jQuery.data() ??? ???

??: data() ???? ??? ??? ???? ????? ??? ???? ???? ?????. ??? ?? ??? ?????. .data()? ???? ?? ? ?????.

??? ?? ??: ??? ???? ?? ???? ?????.

??: ??$(selector).data(??)

????:

ParametersDescription
name?? ?????. ??? ???? ??? ?????. ??? ???? ?? ?? ? ???? ??? ??? ?? ???? ??? ?????.

??? ??? ??: ??? ??? ???? ?????.

??: ??$(selector).data(??,?)

????:

ParametersDescription
name ?????. ??? ???? ??? ?????.
? ?????. ??? ???? ?? ?????.

??? ???? ??? ??? ??: ??/? ?? ?? ??? ???? ??? ??? ???? ?????.

??: ??$(selector).data(object)

????:

ParametersDescription
object ?????. ??/? ?? ???? ??? ?????.?

jquery jQuery.data() ??? ?

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#btn1").click(function(){
    $("div").data("greeting", "Hello World");
  });
  $("#btn2").click(function(){
    alert($("div").data("greeting"));
  });
});
</script>
</head>
<body>
<button id="btn1">把數(shù)據(jù)添加到 div 元素</button><br />
<button id="btn2">獲取已添加到 div 元素的數(shù)據(jù)</button>
<div></div>
</body>
</html>
???? ?? ?

??? ????? ??? "???? ??" ??? ?????