Changing the image source using jQuery

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

My DOM looks like this:

16条回答
  •  情深已故
    2020-11-22 01:58

    For more information. I try setting src attribute with attr method in jquery for ad image using the syntax for example: $("#myid").attr('src', '/images/sample.gif');

    This solution is useful and it works but if changing the path change also the path for image and not working.

    I've searching for resolve this issue but not found nothing.

    The solution is putting the '\' at the beginning the path: $("#myid").attr('src', '\images/sample.gif');

    This trick is very useful for me and I hope it is useful for other.

提交回复
热议问题