javascript - how to change src of img tag using Jquery -
javascript - how to change src of img tag using Jquery -
this question exact duplicate of:
how alter src of img using jquery 1 replythis might straightforward, want alter src of img tag within li tag. there 4 li tags , li tag has class active should alter it's img tag's src.
<ul> <li><img src="example.jpeg" /></li> <li class="active"><img src="notexample.jpeg" /></li> <li><img src="example.jpeg" /></li> <li><img src="example.jpeg" /></li> </ul>
moreover, active class toggles between li tags alter source...
... ... //code changing class ... ... $('li').each(function() { if($(this).attr('class').indexof("active") !== -1) { //active class applied $(this).children().children().attr("src", "assets/img/button_home_selected3.png"); } else { $(this).children().children().attr("src", "assets/img/button_home_plain.png"); } }); ... ...
javascript jquery twitter-bootstrap
Comments
Post a Comment