Skip to content

Instantly share code, notes, and snippets.

@yardfarmer
Created August 21, 2014 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yardfarmer/6f518501dad149be8936 to your computer and use it in GitHub Desktop.
Save yardfarmer/6f518501dad149be8936 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div>
<ul>
<li class='a'>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
</ul>
</div>
<script id="jsbin-javascript">
$('div ul li:first').data('class','hightlight');
b = $('.a').data();
//var c = $('ul').append($('.a').clone()); // 不会带数据
var c = $('ul').append($('.a').clone(true)); // 会带数据
console.log(b,$('div ul li:last').data());
</script>
</body>
</html>
$('div ul li:first').data('class','hightlight');
b = $('.a').data();
//var c = $('ul').append($('.a').clone()); // 不会带数据
var c = $('ul').append($('.a').clone(true)); // 会带数据
console.log(b,$('div ul li:last').data());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment