我有以下HTML
结构:
<ul id="list2">
<li class="_column small">
<img id="YB_random_with_img" src="/cms_agency/Images/CharterWebsite/W350xH300/Articles-(7)-350-300.jpg" alt="Home " title="Home " />
<h2><a href="/cms_agency/more/articles/articles-(7)">Greece</a></h2>
</li>
<li class="_column small">
<img id="YB_random_with_img" src="/cms_agency/Images/CharterWebsite/W720xH300/Articles-(1)-720-300.jpg" alt="Home " title="Home " />
<h2><a href="/cms_agency/more/articles/articles-(1)">Stockholm</a></h2>
</li>
<li class="_column small">
<img id="YB_random_with_img" src="/cms_agency/Images/CharterWebsite/W350xH300/Articles-350-300.jpg" alt="Home " title="Home " />
<h2><a href="/cms_agency/more/articles/articles">Sailing in Italy</a></h2>
</li>
</ul>
我的问题是它找不到._column
中的最大图像,有时会施加小于最大图像的宽度,并且会导致布局出现问题。
我有以下代码:
jQuery(document).ready(function () {
jQuery("._column img").each(function () {
if (this.width > 350) {
jQuery(this.parentNode).addClass('large');
}
else {
jQuery(this.parentNode).addClass('small');
}
});
});
一些消化?谢谢!
答案 0 :(得分:1)