[英]changing src after page load / is executable?
A. I wondering how to change src after page load using Javascript 答:我想知道如何使用Javascript在页面加载后更改src
<img src="http://example.com/image.png" /> to <img src="http://domain.com/different.jpg" />
B. My second question to follow is - will the the new src of the image (domain.com/different.jpg) will be displayed? B.接下来要问的第二个问题是-是否会显示图片的新src(domain.com/different.jpg)? it will execute a new network request? 它将执行一个新的网络请求?
A: This would need to be done client-side (presumably by some javascript). 答:这需要在客户端完成(大概是通过一些javascript)。
B: Yes; B:是的; Any change to a resource's location would (if not already cached) involve another round-trip. 对资源位置的任何更改都会(如果尚未缓存)涉及另一个往返。
Use jquery and write the below code after document ready 准备好文档后使用jquery并编写以下代码
A. $('img').attr('src','http://domain.com/different.jpg');
A. $('img').attr('src','http://domain.com/different.jpg');
B. Yes, the image will display and yes, it will execute a new network request B.是,将显示该图像,是,它将执行一个新的网络请求
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.