Changing the image source using jQuery

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

My DOM looks like this:

16条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 02:01

    You should add id attribute to your image tag, like this:

    then you can use this code to change the source of images:

     $(document).ready(function () {
            $("#img1").attr({ "src": "logo-ex-7.png" });
            $("#img2").attr({ "src": "logo-ex-8.png" });
        });
    

提交回复
热议问题