javascript - on click apply class with different css properties -
i trying apply class on click li
of div
.
this js have.
$(document).ready(function() { $('#toggleme').click(function() { $(this1).addclass('active_class'); }); });
now when click @ cart, want change cart image.
i trying via css applying class background-image:url("");
property. reason not able working.
here's fiddle please help.
change js code this:
$(document).ready(function () { var img=0; $('#toggleme').click(function () { $(this).toggleclass('active_class'); if(img==0){ $(this).find("img").attr("src", 'http://cdn.mysitemyway.com/etc-mysitemyway/icons/legacy-previews/icons-256/simple-red-glossy-icons-business/086707-simple-red-glossy-icon-business-cart5.png'); img=1; }else{ $(this).find("img").attr("src", 'http://www.daru-koi.com/images/winkelwagen.png'); img=0; } }); });
also note icon in code due img
tag source , not css. therefore overwriting using css not help.
the above code switches source everytime click.
Comments
Post a Comment