I have this code, and I want on click on div with favoriteButton class, text in current (this) and src of current img tag to be changed.
Changing text in work fine but image not work.
I try to put another as child of first and code work fine, only in nested img not work
$('.favoriteButton').click(function(e){
$(this).find('.aclass').text("yeeee");
$(this).find('.imgclass').attr("src", "remove_favorit.png");
e.preventDefault();
});
Can some one help me how to solve that using JQuery
Thanks
解决方案
That's because the image is inside the link, so when you change the .text() value of the link, the image disappears. To solve this, take the image outside of the link, or cache it and append it after you change the text.