所以我在HTML中有这个:
<div class="field">
@Html.RadioButton("button1", id1, new { @id = "button1", @class = "radio" })
<label for="button1" class="radio">Label1</label>
@Html.RadioButton("button2", id2, new { @id = "button2", @class = "radio" })
<label for="button2" class="radio">Label2</label>
@Html.RadioButton("button3", id3, new { @id = "button3", @class = "radio" })
<label for="button3" class="radio">Label3</label>
@Html.RadioButton("button4", id4, new { @id = "button4", @class = "radio" })
<label for="button4" class="radio">Label4</label>
</div>
我希望其中一个消失,在我收到的一些情况下,所以看起来像
<div class="field">
@Html.RadioButton("button1", id1, new { @id = "button1", @class = "radio" })
<label for="button1" class="radio">Label1</label>
@Html.RadioButton("button2", id2, new { @id = "button2", @class = "radio" })
<label for="button2" class="radio">Label2</label>
@Html.RadioButton("button3", id3, new { @id = "button3", @class = "radio" })
<label for="button3" class="radio">Label3</label>
</div>
但当然我不能制作两份副本并显示我想要的副本,因为那时我会有一些具有相同ID的按钮,之后我想在我的.js中使用它们。
问题是:有没有办法让我想要的按钮从视图中消失而不会破坏视图? (我试图将单选按钮插入div中,然后在我想要的时候隐藏&#34;(javascript中的.hide()方法),但是当它必须出现时它看起来并不好。