Advertisement
Guest User

Ocultar campos con JQuery

a guest
Jan 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <!doctype html>
  2.  
  3. <html lang="en">
  4. <head>
  5. <meta charset="utf-8">
  6.  
  7. <title>Prueba de ocultado de campos</title>
  8. <meta name="description" content="The HTML5 Herald">
  9. <meta name="author" content="SitePoint">
  10.  
  11. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  12.  
  13. </head>
  14.  
  15. <body>
  16.  
  17. <select id="miSelector" onchange="es_Campo_SPE()">
  18. <option value="normal">Normal</option>
  19. <option value="SPE">SPE</option>
  20. </select>
  21.  
  22. <div class = "esCampoSPE">
  23. <p> Es un campo SPE </p>
  24. </div>
  25.  
  26. <div class = "esCampoNormal">
  27. <p> Es un campo normal </p>
  28. </div>
  29.  
  30.  
  31. <script>
  32.  
  33. $(document).ready(function() {
  34. es_Campo_SPE();
  35. });
  36.  
  37.  
  38.  
  39. function es_Campo_SPE() {
  40.  
  41. var campoTest = $("#miSelector").val();
  42.  
  43. if( campoTest == "SPE") {
  44. $(".esCampoSPE").show();
  45. $(".esCampoNormal").hide();
  46. }
  47. else {
  48. $(".esCampoSPE").hide();
  49. $(".esCampoNormal").show();
  50. }
  51. }
  52.  
  53. </script>
  54.  
  55.  
  56.  
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement