<div id="showArea">
<a href="{dede:field name="litpic"/}" rel="zoom1" rev="{dede:field name="litpic"/}"><img src="{dede:field name="litpic"/}" /></a>
<a href="{dede:field name='litpic1'/}" rel="zoom1" rev="{dede:field name='litpic1'/}" ><img src="{dede:field name='litpic1'/}"/></a>
<a href="{dede:field name='litpic2'/}" rel="zoom1" rev="{dede:field name='litpic2'/}"><img src="{dede:field name='litpic2'/}" /></a>
</div>
href的内容是动态生成的,链接里有个img标签,如果href内容为空就不需要显示这个链接了,要不然图片显示的是个红X
$.each($('#showArea a'),function(){
if($(this).attr('href')==''){
$(this).hide();
}
})追问
大神 能不能详细一点呀,我是新手 囧
追答引入jquery然后用上面的代码
加在你想要执行的地方呀。
比如说有个按钮 点下以后执行
$(function(){
$('#hideA').click(function(){
$.each($('#showArea a'),function(){
if($(this).attr('href')==''){
$(this).hide();
}
});
});
})
这样 点了隐藏按钮a标签就隐藏了
不用按钮呀 ,就是网页打开的时候图片路径为空,那就不显示
这条就行了,
$(function(){
$.each($('#showArea a img'),function(){
if($(this).attr('src')==''){
$(this).parent().hide();
}
});
})
引入jquery
然后这段script 加到页面上
你说的图片路径为空就是src里面没东西,有东西就不管用了