dom.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. $("#getValor").click(function() {
  2. alert($("#inputPrueba").val());
  3. alert($("#parraPrueba").text());
  4. });
  5. $("#setValor").click(function(){
  6. var inputValue = $("#inputPrueba").val();
  7. var pText = $("#parraPrueba").text();
  8. $("#inputPrueba").val(pText);
  9. $("#parraPrueba").text(inputValue);
  10. });
  11. $(function() {
  12. $("#but-appendTo").click(function() {
  13. var li = $( "#myList li:first" ).appendTo( "#myList" );
  14. alert(li.text());
  15. });
  16. $("#but-append").click(function() {
  17. $( "#myList" ).append( $( "#myList li:first" ) );
  18. });
  19. });
  20. $(function() {
  21. $("#clone-appendTo").click(function() {
  22. $( "#myList2 li:first" ).clone().appendTo( "#myList2" );
  23. });
  24. });
  25. $(".yellow, .yellow2, .yellow3").click(function() {
  26. alert("soy un párrafo amarillo");
  27. });
  28. var parra;
  29. $( "#use-remove" ).click(function() {
  30. parra = $( ".yellow" ).remove();
  31. });
  32. $( "#add-remove" ).click(function() {
  33. $( "#insertParra" ).append(parra);
  34. });
  35. var parra2;
  36. $( "#use-detach" ).click(function() {
  37. parra2 = $( ".yellow2" ).detach();
  38. });
  39. $( "#add-detach" ).click(function() {
  40. $( "#insertParra2" ).append(parra2);
  41. });
  42. var parra3;
  43. $( "#use-empty" ).click(function() {
  44. parra3 = $( ".yellow3" ).empty();
  45. });
  46. $( "#add-empty" ).click(function() {
  47. $( "#insertParra3" ).append(parra3);
  48. });
  49. $(function() {
  50. $("#mod-resource").click(function(){
  51. var form = $("<form/>", {method:'post', action:'index.php', id:'form_res'
  52. });
  53. var select = $("<select/>", {name:"type_student",id:"select-res"});
  54. select.append($("<option/>", {value:"adulto", text:"Adulto"}),
  55. $("<option/>", {value:"empresarial", text:"Empresarial/Profesional"}),
  56. $("<option/>", {value:"primaria", text:"Escuela Primaria"})
  57. );
  58. var radio = $("<div>", {class:"radio-mod radio-mod"});
  59. radio.append($("<input>", {type:"radio", name:"level", value:"a1"}),
  60. $("<label>", {text:"A1"}),
  61. $("<input>", {type:"radio", name:"level", value:"a2"}),
  62. $("<label>", {text:"A2"})
  63. );
  64. form.append($("<label>", {class:'mod-label', text:"LEVEL*"}),
  65. $(radio),
  66. $("<label>", {class:'mod-label', text:"STUDENT TYPE*"}),
  67. $(select)
  68. );
  69. $('#form-added').append(form);
  70. });
  71. });
  72. $(function() {
  73. $("#changeHref").click(function() {
  74. $("#duck").attr( "href", "https://www.mozilla.org" );
  75. });
  76. $("#changeAtt").click(function() {
  77. $("#duck2").text("Ir a google");
  78. $("#duck2").attr({
  79. href: "https://www.google.es",
  80. id: "google",
  81. });
  82. });
  83. });
  84. $("#removeHref").click(function() {
  85. $("#google2").removeAttr("href");
  86. });
  87. $(function() {
  88. $("#specialBig").hover(function() {
  89. $(this).removeClass("specialBig").addClass("specialLittle");
  90. },
  91. function() {
  92. $(this).removeClass("specialLittle").addClass("specialBig");
  93. });
  94. });
  95. $( ".parraCSS" )
  96. .on( "mouseenter", function() {
  97. $( this ).css({
  98. "background-color": "yellow",
  99. "font-weight": "bolder"
  100. });
  101. })
  102. .on( "mouseleave", function() {
  103. var styles = {
  104. backgroundColor : "#ddd",
  105. fontWeight: ""
  106. };
  107. $( this ).css( styles );
  108. });