I have a jQuery code that is used to show and hide responses. What I want to achieve is that instead of showing the "see answer" or "hide answer" text, it shows an icon, for example a fa icon ( fa fa-plus
). How do I make it possible?
// jQuery
$(document).ready(function(){
$('#alternar-respuesta-ej5').toggle(
// Primer click
function(e){
$('#respuesta-ej5').slideDown();
$(this).text('Ocultar respuesta');
e.preventDefault();
}, // Separamos las dos funciones con una coma
// Segundo click
function(e){
$('#respuesta-ej5').slideUp();
$(this).text('Ver respuesta');
e.preventDefault();
}
);
});
I made a little code I hope it helps you: