js(javascript)判断图片是否存在,如果不存在,显示默认图片
<script src="/libs/jquery/2.1.4/jquery.min.js " ></script> <img class="top-img" src="" alt="" /><script type="text/javascript">var img1 = $(".top-img").attr("src");if(img1 == ""){$("img").attr("src","img2.jpg");}</script>