[Answer]-Why does my function .show of jquery doesnt work on a button

1👍

You have syntax errors, and add the script in dom ready hadnler

jQuery(function () {
    function doIt() {
        $(".cambio-imagen").show("slow");
    }
    $("#boton-imagen").click(doIt);
    $("#form-cambio-imagen").submit(function (event) {
        $(".cambio-imagen").hide("fast");
    });
});

0👍

Errors in your script call Document ready

$(document).ready(function(){
    function doIt() {
        $(".cambio-imagen").show("slow");
    }
    $("#boton-imagen").click(doIt);
    $("#form-cambio-imagen").submit(function (event) {
        $(".cambio-imagen").hide("fast");
    });
});

0👍

Kindly use jquery toggle method. You can able to achieve your requirements.

Check this URL : http://api.jquery.com/toggle/

0👍

Try like

$("#boton-imagen").click(function(){
    doIt();
});

And you have syntax errors too..Try like

<script>
   $(document).ready(function(){
       $("#boton-imagen").click(function(){
          $(".cambio-imagen").show("slow");
       });
       $("#form-cambio-imagen").submit(function (event) {
           $(".cambio-imagen").hide("fast");
       });    
   });
</script>

0👍

Try it :

function doIt() {
      $(".cambio-imagen").show("slow");
}

$("#boton-imagen").click(
    doIt();
);

$("#form-cambio-imagen").submit(function (event) {
      $(".cambio-imagen").hide("fast");
  });

Leave a comment