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 reply

this 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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -