需要实现的功能是:
后台有5个上传产品缩略图的选项,前台调用后台的是src="后台上传的路径"
现在我需要做一个判断,当后台没有上传图片的时候就隐藏这个img标签
<script type="text/javascript">
var litpic2 = document.getElementById("litpic2");
if(litpic2){
var pic2 = document.getElementById("litpic2").src;
var pic2_2 = location.href.substring(0,location.href.lastIndexOf('/')+1);
if(pic2 == null || pic2 == pic2_2){
document.getElementById("litpic2").style.display = "none";
}
}
var litpic3 = document.getElementById("litpic3");
if(litpic3){
var pic3 = document.getElementById("litpic3").src;
var pic3_3 = location.href.substring(0,location.href.lastIndexOf('/')+1);
if(pic3 == null || pic3 == pic3_3){
document.getElementById("litpic3").style.display = "none";
}
}
var litpic4 = document.getElementById("litpic4");
if(litpic4){
var pic4 = document.getElementById("litpic4").src;
var pic4_4 = location.href.substring(0,location.href.lastIndexOf('/')+1);
if(pic4 == null || pic4 == pic4_4){
document.getElementById("litpic4").style.display = "none";
}
}
var litpic5 = document.getElementById("litpic5");
if(litpic5){
var pic5 = document.getElementById("litpic5").src;
var pic5_5 = location.href.substring(0,location.href.lastIndexOf('/')+1);
if(pic5 == null || pic5 == pic5_5){
document.getElementById("litpic5").style.display = "none";
}
}
</script>
请教各位大神一个关于JS控制文本框隐藏显示的问题
首先将文本框隐藏掉 js通过触发事件来显示文本框 我们动手实现一个小例子 <!DOCTYPE html> <html lang=""> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>js控制元素的显示与隐藏<\/title> <style type="text\/css"> { m...