为什么这个命令在jquery中不起作用?

时间:2017-03-06 00:05:47

标签: jquery

我正在使用JSFiddle,但我没有让控制台加载。

http://jsfiddle.net/RPpXu/

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>

请帮帮我

0 个答案:

没有答案