图片切换实现选中-未选中效果

      预先准备两张图片表示选中与未选中,当点击该元素时进行选中与未选中图片的切换,即可实现选中与未选中,然后根据该元素的src属性判断是否选中,然后判断该执行什么操作:

    <div class="way-choose ">
        <img  class="choose radio-select" src="select.png"/>
    </div>
$(".way-choose").click(function(obj){
    if($(".choose").attr("src")=="select.png"){
        $(".choose").attr("src","not-select.png");
    }else if($(".choose").attr("src")=="not-select.png"){
        $(".choose").attr("src","select.png");
    }
});
if($(".choose").attr("src")=="select.png"){
   alert("选中了");

}else if($(".choose").attr("src")=="not-select.png"){
   alert("未选中")  
}
原文地址:https://www.cnblogs.com/haimengqingyuan/p/8570274.html