script jquery stops working

0

I have a jquery code that hides and shows an answer ... but when I paste it several times to activate several answers it stops working, code:

<a href='#' id='alternar-respuesta-ej1' style='float: left; color: #ff0000;'>Mostrar respuesta</a><div id='respuesta-ej1' style='display:none'>-- RESPUESTAS--</div>

and the jquery code, which I've pasted several times (more than 30 times) in different script tags as the conversation ends.

// jQuery
$(document).ready(function(){ 

$(&#39;#alternar-respuesta-ej1&#39;).toggle( 

        // Primer click
        function(e){ 
            $(&#39;#respuesta-ej1&#39;).slideDown();
          $(this).text(&#39; ocultar respuestas &#39;);
            e.preventDefault();
        }, // Separamos las dos funciones con una coma

        // Segundo click
        function(e){ 
            $(&#39;#respuesta-ej1&#39;).slideUp();
            $(this).text(&#39;mostrar  respuesta&#39;);
            e.preventDefault();
        }

    );
  });
    
asked by code2018 10.10.2018 в 00:34
source

0 answers