Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>LAB02</title>
  6. <style>
  7. .caja{
  8. width:120px;
  9. height:120px;
  10. background-color:#FF9900;
  11. position:relative;
  12. }
  13. </style>
  14. </head>
  15.  
  16. <body>
  17. <div class="caja"></div>
  18. <p id="muestra"></p>
  19. <button name="muestra">Ejemplo JQuery</button>
  20. <button name="mover">Ejemplo JQuery mover</button>
  21. <button name="getdatos">GET data</button>
  22. <script src="js/jquery.js"></script>
  23. <script>
  24. //$(selector).action()
  25. //# = ID
  26. //. = CLASS
  27. $(document).ready(function(){
  28. var texto = "Hola Mundo desde Jquery";
  29. $("#muestra").html(texto);
  30. $("button[name='muestra']").click(function(){
  31. alert("Ejemplo boton");
  32. })
  33. $("button[name='mover']").click(function(){
  34. $(".caja").animate({left:250}).hide(1000);
  35. });
  36. $("button[name='getdatos']").click(function(){
  37. //AJAX
  38. var endpoint = "https://jsonplaceholder.typicode.com/posts";
  39. $.get(endpoint,function(data){
  40. $.each(data,function(idx,valor){
  41. respuesta = "<br />UserID: "+valor.userId+" T&iacute;tulo: "+valor.title+"<br />";
  42. $("#muestra").append(respuesta);
  43. });
  44. });
  45. });
  46. });
  47. </script>
  48. </body>
  49.  
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement