Guest User

Untitled

a guest
May 27th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. var $el = $("<div>", { "data-row-idx": 1, "data-col-idx": 2 })
  2. // n.fn.init [div]
  3.  
  4. $el.data("row-idx")
  5. // 1
  6.  
  7. $el.data("col-idx")
  8. // 2
  9.  
  10. ["row-idx", "col-idx"].map(function(x) { return $el.data(x) })
  11. // (2) [1, 2]
  12.  
  13. ["row-idx", "col-idx"].map($el.data)
  14. // jquery.min.js:3 Uncaught TypeError: this.each is not a function
  15. // at data (jquery.min.js:3)
  16. // at Array.map (<anonymous>)
  17. // at <anonymous>:1:24
  18. // data @ jquery.min.js:3
  19.  
  20. [1,2,3].map(function(x) { return x})
  21. // (3) [1, 2, 3]
  22.  
  23. ["row-idx", "col-idx"].map(function(x) { return $el.data(x) })
  24.  
  25. ["row-idx", "col-idx"].map($el.data)
Add Comment
Please, Sign In to add comment