jQuery控制多个图片大小 $(document).ready(function() { var maxwidth = 340; if ($("#proc img").attr("width") > maxwidth) { $("#proc img").attr("width", 340); }; })这段代码智能把"proc"下的第一个图片控制大小,其他都不可以.该怎么修改来实现"proc"下所有的图片都可以被控制大小 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 该怎么修改来实现"proc"下所有的图片都可以被控制大小?你指的是#proc下的所有同级层关系的IMG,包括父层吗?或者整个BOYD里的?把代码里的选择符$("#proc img")改为:$("#proc~img"),意思就是寻找所有和#proc同级的img元素! 如果你指的意思是#proc下的img,也就是都是被#proc包围的子img,那么#proc img就可以了。 <table id="proc"> <tr> <td><img ></td> <td><img></td> <td><img></td></tr></table>这种模式 OK测试一下吧!<script type="text/javascript" src="jquery.js"></script><script type="text/javascript">$(function(){var maxwidth = 340;$('#proc img').each(function(i,obj){ if($(obj).width()>maxwidth) {$(obj).width(340);} });});</script><table id="proc"> <tr> <td><img src='444.jpg'></td> <td><img src='444.jpg'></td> <td><img src='444.jpg'></td></tr></table> $(document).ready(function() { var maxwidth = 340; $("#proc img").each(function(){ if(&(this).attr("width") > maxwidth)) $(this).attr("width", maxwidth); });}) if(&(this).attr("width") > maxwidth))多写了个反括号 高手们哪,字符串倒 来来来看段代码,这是哪的毛病? 谁能帮帮把这段改成不需要form的 如何在在iframe里加入onkeyup事件 请教meizz【梅花雪】tree控件。 如何模拟在控件上的双击操作?即双击的方法 如何用javascript将下列一段xml代码显示为树状? 如何修改<img>的激活区大小? 没法!我实在是太笨了 急~~~~!·!!!!! 我想在页面加载的时候设置frame的src怎么没效果 定时刷新页面的方法
把代码里的选择符$("#proc img")改为:$("#proc~img"),意思就是寻找所有和#proc同级的img元素!
<table id="proc">
<tr>
<td><img ></td>
<td><img></td>
<td><img></td>
</tr>
</table>这种模式
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function(){
var maxwidth = 340;
$('#proc img').each(function(i,obj){
if($(obj).width()>maxwidth)
{$(obj).width(340);}
});
});
</script>
<table id="proc">
<tr>
<td><img src='444.jpg'></td>
<td><img src='444.jpg'></td>
<td><img src='444.jpg'></td>
</tr>
</table>
$(document).ready(function() {
var maxwidth = 340;
$("#proc img").each(function(){
if(&(this).attr("width") > maxwidth))
$(this).attr("width", maxwidth);
});
})