Advertisement
kacci97

Oblivion

Jan 15th, 2019
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Movies</title>
  6. <link rel="stylesheet" href="jquery/jquery-ui.css">
  7. <style>
  8. #desc{
  9. background-color: aliceblue;
  10. width: 220px;
  11. padding: 5px;
  12. border: dotted 2px darkgray;
  13. display: none;
  14. }
  15. .ui-autocomplete{
  16. width: 1200px;
  17. }
  18. </style>
  19. <script src = "jquery/jquery.js"></script>
  20. <script src = "jquery/jquery-ui.js"></script>
  21. </head>
  22. <body>
  23. <label>Select a movie:</label>
  24. <br>
  25. <input id="input">
  26. <br>
  27. <br>
  28. <div id="desc"></div>
  29. <script>
  30. var movies = [
  31. {
  32. label: "Oblivion",
  33. desc: "A veteran assigned to extract Earth's remaining resources begins to question what he knows about his mission and himself."
  34. },
  35. {
  36. label: "Ender's Game",
  37. desc: "Young Ender Wiggin is recruited by the International Military to lead the fight against the Formics, a genocidal alien race which nearly annihilated the human race in a preious invasion."
  38. },
  39. {
  40. label: "Elysium",
  41. desc: "In the year 2154, the very wealthy live on a man-made space station while the rest of the population resides on a ruined Earth. A man takes on a mission that could bring equality to the polarized worlds."
  42. }
  43. ];
  44.  
  45. $("#input").autocomplete({
  46. source: movies,
  47. minLength: 0,
  48. focus: function( event, ui ) {
  49. $( "#input" ).val( ui.item.label );
  50. return false;
  51. },
  52. select: function( event, ui ) {
  53. $("#input").val(ui.item.label);
  54. $("#desc").html(ui.item.desc).show();
  55. }
  56. }).autocomplete( "instance" )._renderItem = function( ul, item ) {
  57. return $( "<li>" )
  58. .append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
  59. .appendTo( ul );
  60. }
  61. </script>
  62. </body>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement