[英]hide div when isset on input
I met a trouble with a script I'm doing, 我在写脚本遇到麻烦,
In fact it does not work. 实际上,它不起作用。
What I would like to do is to make draggable some divs, and to put there content into an iput type text. 我想做的是使一些div成为可拖动对象,然后将内容放入iput类型的文本中。 For that I wrote a function like that:
为此,我编写了这样的函数:
function checkdiv()
{
var position1= document.getElementById("position1").value;
if(position1=="1")
{
document.getElementById("1").style.display = "none"
}
if(position1==2)
{
document.getElementById("2").style.display = "none"
}
if(position1==3)
{
document.getElementById("3").style.display = "none"
}
if(position1==4)
{
document.getElementById("4").style.display = "none"
}
if(position1==5)
{
document.getElementById("5").style.display = "none"
}
if(position1==6)
{
document.getElementById("6").style.display = "none"
}
if(position1==7)
{
document.getElementById("7").style.display = "none"
}
if(position1==8)
{
document.getElementById("8").style.display = "none"
}
if(position1==9)
{
document.getElementById("9").style.display = "none"
}
if(position1==10)
{
document.getElementById("10").style.display = "none"
}
if(position1==11)
{
document.getElementById("11").style.display = "none"
}
if(position1==12)
{
document.getElementById("12").style.display = "none"
}
if(position1==13)
{
document.getElementById("13").style.display = "none"
}
}
checkdiv();
But it does not really work. 但这并没有真正起作用。
I would like to make disappear div when they a re put into input and to make come them back if the input is set empty or with an other content. 当输入重新输入时,我想使它们消失;如果输入设置为空或具有其他内容,则使它们返回。
Here is the jsfiddle. 这是jsfiddle。 http://jsfiddle.net/FqM4A/13/
http://jsfiddle.net/FqM4A/13/
receive all my utmost Respect. 得到我最大的尊重。
Kind Regards. 亲切的问候。
SP. SP。
There were quite a few issues there, the HTML is very outdated, but I presume this is just a learning exercise, see working code here: 那里有很多问题,HTML太过时了,但是我想这只是一个学习练习,请参见此处的工作代码:
http://jsfiddle.net/FqM4A/22/ http://jsfiddle.net/FqM4A/22/
Note that IDs for elements shouldn't start with a number. 请注意,元素的ID不应以数字开头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.