日期:2014-05-16  浏览次数:20327 次

新手提问,javascript怎样判断src空?
<ul class="thumbs">
<li><img onmouseover="switch_product_img(this);" src="images/01.jpg" /></li>
<li><img onmouseover="switch_product_img(this);" src="images/02.jpg" /></li>
<li><img src="images/03.jpg" onmouseover="switch_product_img(this);" /></li>
<li><img src="images/04.jpg" onmouseover="switch_product_img(this);" /></li>
<li><img src="images/05.jpg" onmouseover="switch_product_img(this);" /></li>
<li><img onmouseover="switch_product_img(this);" src="" /></li>
</ul>
<script language="javascript" type="text/javascript">
var th = document.getElementsByTagName("li");
for (i = 0; i<th.length; i++){
var ths = th[i].getElementsByTagName("img");
for (j = 0; j<ths.length; j++){
if (ths[j].src==""){
th[i].style.display = "none";
}
}
}
</script>
不知道(ths[j].src=="")怎么判断不了?请高手指点一下,谢谢

------解决方案--------------------
.src 换成.getAttribute('src')