Changing the image source using jQuery

前端 未结 16 2292
天命终不由人
天命终不由人 2020-11-22 01:24

My DOM looks like this:

16条回答
  •  野性不改
    2020-11-22 02:21

    Change the image source using jQuery click()

    element:

        
    

    code:

        $(".letstalk").click(function(){
            var newsrc;
            if($(this).attr("src")=="/images/chatbuble.png")
            {
                newsrc="/images/closechat.png";
                $(this).attr("src", newsrc);
            }
            else
            {
                newsrc="/images/chatbuble.png";
                $(this).attr("src", newsrc);
            }
        });
    

提交回复
热议问题