我正在使用JSFiddle,但我没有让控制台加载。
var dataList = $(".list").map(function() {
return $(this).data("id");
}).get();
console.log(dataList.join("|"));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li class="list" data-id="123">One</li>
<li class="list" data-id="124">Two</li>
<li class="list" data-id="125">Three</li>
<li class="list" data-id="126">Four</li>
</ul>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>form ajax</title>
<a href="http://jquery.com/">jQuery</a>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script>
var dataList = $(".list").map(function() {
return $(this).data("id");
}).get();
console.log(dataList.join("|"));
</script>
</head>
<body>
<ul>
<li class="list" data-id="123">One</li>
<li class="list" data-id="124">Two</li>
<li class="list" data-id="125">Three</li>
<li class="list" data-id="126">Four</li>
</ul>
</body>
</html>
请帮帮我