DISUCZ 分类信息中分析字段为空时不显示某DIV
做菜谱的时候,在这个字段为空的时候,这个DIV不显示
上代码,当时取的字符串,因为有HTML标识老出错。
<script> window.onload = function() { var newcss = document.getElementById('testflash').name; var mm = newcss.indexOf('无'); if (mm >= 0) { var div1 = document.getElementById("testflash1"); div1.style.display = "none"; }; var test1="{caitu1_value}"; if (test1 == "") { document.getElementById("all1").style.display = "none"; }; var test2="{caitu2_value}"; if (test2 == "") { document.getElementById("all2").style.display = "none"; }; var test3="{caitu3_value}"; if (test3 == "") { document.getElementById("all2").style.display = "none"; }; var test4="{caitu4_value}"; if (test4 == "") { document.getElementById("all4").style.display = "none"; }; var test5="{caitu5_value}"; if (test5 == "") { document.getElementById("all5").style.display = "none"; }; var test6="{caitu6_value}"; if (test6 == "") { document.getElementById("all6").style.display = "none"; }; var test7="{caitu7_value}"; if (test7 == "") { document.getElementById("all7").style.display = "none"; }; var test8="{caitu8_value}"; if (test8 == "") { document.getElementById("all8").style.display = "none"; }; var test9="{caitu9_value}"; if (test9 == "") { document.getElementById("all9").style.display = "none"; }; var test10="{caitu10_value}"; if (test10.indexOf('nophoto.gif') >=0) { document.getElementById("all10").style.display = "none"; }; var test11="{caitu11_value}"; if (test11.indexOf('nophoto.gif') >=0) { document.getElementById("all11").style.display = "none"; }; var test12="{caitu12_value}"; if (test12.indexOf('nophoto.gif') >=0) { document.getElementById("all12").style.display = "none"; }; } </script>
因为上面是用的JS,要加载所有完页面才使用,肯定不行拉,得让他一加载完DOM就开始,要用到ready(),这是jq,但JQ有和DISCUZ有冲突 ,一定要按下面的写,最下面的是错的
<script> jQuery(document).ready(function() { });
<script> $(document).ready(function () { var newcss = document.getElementById('testflash').name; var mm = newcss.indexOf('无'); if (mm >= 0) { var div1 = document.getElementById("testflash1"); div1.style.display = "none"; }; var test1="{caitu1_value}"; if (test1.indexOf('nophoto.gif') >=0) { document.getElementById("all1").style.display = "none"; }; var test2="{caitu2_value}"; if (test2.indexOf('nophoto.gif') >=0) { document.getElementById("all2").style.display = "none"; }; var test3="{caitu3_value}"; if (test3.indexOf('nophoto.gif') >=0) { document.getElementById("all3").style.display = "none"; }; var test4="{caitu4_value}"; if (test4.indexOf('nophoto.gif') >=0) { document.getElementById("all4").style.display = "none"; }; var test5="{caitu5_value}"; if (test5.indexOf('nophoto.gif') >=0) { document.getElementById("all5").style.display = "none"; }; var test6="{caitu6_value}"; if (test6.indexOf('nophoto.gif') >=0) { document.getElementById("all6").style.display = "none"; }; var test7="{caitu7_value}"; if (test7.indexOf('nophoto.gif') >=0) { document.getElementById("all7").style.display = "none"; }; var test8="{caitu8_value}"; if (test8.indexOf('nophoto.gif') >=0) { document.getElementById("all8").style.display = "none"; }; var test9="{caitu9_value}"; if (test9.indexOf('nophoto.gif') >=0) { document.getElementById("all9").style.display = "none"; }; var test10="{caitu10_value}"; if (test10.indexOf('nophoto.gif') >=0) { document.getElementById("all10").style.display = "none"; }; var test11="{caitu11_value}"; if (test11.indexOf('nophoto.gif') >=0) { document.getElementById("all11").style.display = "none"; }; var test12="{caitu12_value}"; if (test12.indexOf('nophoto.gif') >=0) { document.getElementById("all12").style.display = "none"; }; }); </script>