1、jquery方式:
$("#img").attr("src",url)2、原生javascript方式:
var element = document.getElementById('myimage')element.src = "image/a/053120.jpg"
用setAtrribute()方法
举个例子
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<img src="1.jpg" alt="">
<script>
//获取到图片标签标签
var img = document.getElementsByTagName("img")[0]
//设置图片路径
img.setAttribute("src","2.jpg")
</script>
</body>
</html>