How To Change Src Of Img Using Jquery
I have dynamically added new li tags and they are suppose to show different images based on the class active which toggles on click, but I just cant get the hold of it. I know that
Solution 1:
Try this:
...
...
//code where you are changing the class
...
...
$('li').each(function() {
    if($(this).class().indexOf("active") !== -1)
    {
        //Active class is applied
        $(this).children().children().attr("src", "assets/img/button_home_selected3.png");
    }
    else
    {
        $(this).children().children().attr("src", "assets/img/button_home_plain.png");
    }
});
...
...
Post a Comment for "How To Change Src Of Img Using Jquery"