javascript - 替换 src 中的拇指大小
问题描述
我有这个代码:
<div class="track">
<a href="#" rel="loadpage"><img src="http://localhost/thumb.php?src=2015381915_1861178087_859395037.jpg&t=m&w=112&h=112" alt="alt"></a
</div>
所以,我想用 js 改变“112&h=112”的大小。感谢您的任何建议!
解决方案
所以,这段代码对我有用!
<script type="text/javascript">
window.onload=function(){
$("img").each(function(){
var src=$(this).attr("src");
src=src.replace("112&h=112","200&h=200");
var src=$(this).attr("src",src);
});
}
</script>
推荐阅读
- c - 我在 C 中的动态海量有一些麻烦(只有 C,没有 C++)
- javascript - 自定义字体未加载到 Material UI 的自定义主题上
- jmeter - log4j2.xml 设置以禁用 JMeter 中的日志记录
- nestjs - 如何启用 NestJs swagger 4.x 插件
- laravel - Vue 组件未在其他刀片中显示
- python - 如何在 Python 中遍历嵌套的 JSON
- google-app-engine - 如何从 Google App Engine 中的单个 app.yaml 文件部署 Java 应用程序的多个版本
- amazon-web-services - 有没有一种方法可以限制某个区域的 AWS CloudFront 分配以节省成本?
- exception - 如何以编程方式检测 dotnet.exe 何时遇到第二次机会异常?
- visual-studio - 如果我想将会话超时增加到 60 分钟,是否足以在 Web.config 中进行更改,或者还需要调整 IIS?