Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- function getData(year) {
- $.ajax({
- url:"http://ergast.com/api/f1/"+year+"/drivers.json",
- dataType: "json",
- success: function (data) {
- $.each(data.MRData.DriverTable.Drivers, function (i, item) {
- list_item = $("<li></li>")
- list_item.append(item.givenName+" " + item.familyName)
- list_item.attr("url", item.url)
- list_item.attr("nat", item.nationality)
- list_item.attr("date_of_birth", item.dateOfBirth)
- list_item.appendTo("#"+year)
- })
- }
- })
- }
- getData("2016")
- getData("2017")
- $(document).on("click", "#fav li", function () {
- $("#date").html($(this).attr("date_of_birth"))
- $("#url").attr("href",$(this).attr("url"))
- $("#url").html("Driver info")
- $("#nat").html($(this).attr("nat"))
- })
- $("#2016, #2017").sortable({
- connectWith:"#fav"
- })
- $("#fav").sortable({})
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement