apl-mhd

Image Download update

Nov 4th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--suppress ALL -->
  3. <html>
  4. <head>
  5.     <title></title>
  6.  
  7.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  8.  
  9.  
  10.  
  11. </head>
  12. <body id="result">
  13.  
  14. <ul id="info"></ul>
  15.  
  16.  
  17. <p> Name: <input type="text" id="nane"> </p>
  18. <p> Drink: <input type="text" id="drink"> </p>
  19.  
  20. <button type="button" id="add">Add</button>
  21.  
  22.  
  23. <p id="link"></p>
  24.  
  25. <div id="result">
  26.  
  27.  
  28.  
  29. </div>
  30.  
  31.  
  32. <script type="text/javascript">
  33.    
  34.    
  35.    
  36.     $(document).ready(function () {
  37.  
  38.  
  39.         $.get("https://unsplash.com/t/wallpapers", function(html){
  40.             var txt = $(html).find('a');
  41.  
  42.  
  43.             for (i=0; i<txt.length;i++) {
  44.  
  45.                var link= txt[i].title.split(' ').join('');
  46.  
  47.                if( link == 'Downloadphoto' ) {
  48.  
  49.  
  50.                    var img = '<img style="width:  100px; height: 100px;" src='+ txt[i].href +'>';
  51.  
  52.                     $('#result').append(img);
  53.  
  54.                     console.log(txt[i].href);
  55.  
  56.                 }
  57.  
  58.             }
  59.  
  60.             console.log(txt.length);
  61.  
  62.            // $("#wikiModal h4.modal-title").text(txt);
  63.         });
  64.  
  65.  
  66.     });
  67.  
  68.     /*var $list = $('#info');
  69.  
  70.     var $name = $('#name');
  71.     var $drink = $('#drink');
  72.  
  73.     $(function () {
  74.  
  75.         $.ajax({
  76.             type: 'GET',
  77.             dataType: 'json',
  78.             url: 'info.json',
  79.             success: function (datas) {
  80.  
  81.                 $.each(datas, function (i, data) {
  82.  
  83.                     $list.append( '<li>'+  data.name  +'</li>');
  84.  
  85.                     console.log(data.age);
  86.                 })
  87.  
  88.             }
  89.         });
  90.  
  91.         $('#add').on('click', function () {
  92.             var  order ={
  93.  
  94.                 drink: $drink.val(),
  95.                 name: $name.val(),
  96.  
  97.             };
  98.  
  99.          $.ajax({
  100.  
  101.              type: 'POST',
  102.              url: 'info.json',
  103.              data: order,
  104.              
  105.              success:function (newOrder) {
  106.  
  107.                  $list.append( '<li>'+  newOrder  +'</li>');
  108.              },
  109.  
  110.              error:function () {
  111.  
  112.                  console.log('error');
  113.              }
  114.  
  115.          })
  116.  
  117.  
  118.         })
  119.  
  120.  
  121.  
  122.     })*/
  123.  
  124. </script>
  125. </body>
  126. </html>
Add Comment
Please, Sign In to add comment