Dear friends, I am a student and curious about it, not an experienced programmer, hence my question.
Come on, JQUERY's "ON ()" method can be associated with several types of events ("click", "mouseleave", etc.), including more than one at the same time, right ?! Well, through the "ON" method and a "CLICK" event, I tried to associate a change in the "SRC" of the image (in "ALT" and "TITLE", too). What I expected would happen, which was basically to change the image by clicking on it, it happens unsatisfactorily, the image changes very quickly and does not remain with the change, as you would expect. It only occurs at the instant of the click and back to what it was after releasing the mouse button.
Follow the HTML, images and JQUERY for review. (Thanks in advance for your help!)
HTML
<a href=""> <!-- Espanha --> <img class="img-esp" src="img/esp.png" alt="España" title="España" /></a>
IMAGES (Flags)
JQUERY
$(document).ready(function(){$(".img-esp").on("click", function() {
//Mudar a bandeirinha para a do Brasil (idioma português)
$(this).attr("src", "img/bra.png");
//Mudar o atributo ALT da bandeirinha (idioma português)
$(this).attr("alt", "Português (Brasil)");
//Mudar o atributo TITLE da bandeirinha (idioma português)
$(this).attr("title", "Português (Brasil)");
});
});