Advertisement
LegoDrifter

Untitled

Jan 12th, 2021
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. $(document).ready(function () {
  2.  
  3. function getData(year) {
  4. $.ajax({
  5. url:"http://ergast.com/api/f1/"+year+"/drivers.json",
  6. dataType: "json",
  7. success: function (data) {
  8. $.each(data.MRData.DriverTable.Drivers, function (i, item) {
  9. list_item = $("<li></li>")
  10. list_item.append(item.givenName+" " + item.familyName)
  11. list_item.attr("url", item.url)
  12. list_item.attr("nat", item.nationality)
  13. list_item.attr("date_of_birth", item.dateOfBirth)
  14. list_item.appendTo("#"+year)
  15. })
  16. }
  17. })
  18.  
  19. }
  20.  
  21. getData("2016")
  22. getData("2017")
  23.  
  24. $(document).on("click", "#fav li", function () {
  25. $("#date").html($(this).attr("date_of_birth"))
  26. $("#url").attr("href",$(this).attr("url"))
  27. $("#url").html("Driver info")
  28. $("#nat").html($(this).attr("nat"))
  29. })
  30.  
  31. $("#2016, #2017").sortable({
  32. connectWith:"#fav"
  33. })
  34. $("#fav").sortable({})
  35. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement