英文:
Reset div tag after alert has been closed
问题
当满足条件时,我出现了一个错误消息。消息框的角落有一个小叉,以便用户可以关闭消息。然而,一旦关闭了消息,之后再次出现相同的错误时,消息框不再出现。如何“重置”div类以使其重新出现?
@if (condition == true)
{
<div class="alert">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
<strong>Error!</strong> An error has been identified
</div>
}
再次满足条件,但错误框不弹出。
英文:
I have an error message that pops up when a condition is met. There is a small cross in the corner of the message box so that the user can get rid of the message. However once this is done and the same error is made later on the message box does not reappear. How can I "reset" the div class so that it reappears?
@if (condition == true)
{
<div class="alert" >
<span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
<strong>Error!</strong> An error has been identified
</div>
}
The condition is met again but the error box doesn't pop up
答案1
得分: 0
@if (condition == true)
{
<div class="alert" >
<span class="closebtn" onclick="Dissapear">×</span>
<strong>Error!</strong> An error has been identified
</div>
}
public void Dissapear()
{
condition = false;
}
我添加了一个方法,但也许你可以在点击事件内部更改条件。
英文:
@if (condition == true)
{
<div class="alert" >
<span class="closebtn" onclick="Dissapear">&times;</span>
<strong>Error!</strong> An error has been identified
</div>
}
public void Dissapear()
{
condition = false;
}
I added a method but perhaps you could change the condition within the onclick event itself
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论