有两个标签.我想要的是单击标签1->标签上的数据将显示和隐藏 [英] There are two labels. What i want is on click label1--> data on label will be shown and hidden
本文介绍了有两个标签.我想要的是单击标签1->标签上的数据将显示和隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以执行其中的一部分,即点击"label1"->数据将显示在label2上.现在,请告诉我如何通过单击label1隐藏label2上的数据.
代码:
I am able to do one part of it i.e. on click label1--> data will be shown on label2. Now please tell me how to hide data on label2 by clicking label1.
code:
<script type="text/C#" runat= "server">
protected void Page_Load(object sender, EventArgs e)
{
label1.Attributes.Add("onclick", "label2show()");
}
</script>
<script type="text/javascript">
function label2show()
{
document.getElementById('label2').innerHTML = 'show data';
}
</script>
<asp:Label runat="server" ID="label1">Press it to show and hide data on label 2</asp:Label>
<asp:Label runat="server" ID="label2"></asp:Label>
推荐答案
将javascript
函数更改为此:
Change thejavascript
function to this:
function label2show()
{
if(document.getElementById('label2').innerHTML == '')
document.getElementById('label2').innerHTML = 'show data';
else
document.getElementById('label2').innerHTML = '';
}
非常感谢.这么简单
我必须为这个愚蠢的错误打个电话**
Thanks a lot ankur. Its so simple
I have to kick my a** for this silly mistake
您能不能再解释一下.我们如何单击Label?...
can u please explain little more..How can we click on Label?...
这篇关于有两个标签.我想要的是单击标签1->标签上的数据将显示和隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文