我正在为我一直在研究的表单尝试一些 JS。如果他们的用户没有选择是,目的是隐藏。这是我遇到的一些问题:HTML:
<asp:RadioButtonList runat="server" ID="rbMatchingGift" ClientIDMode="Static">
<asp:ListItem Value="0" Text="No"></asp:ListItem>
<asp:ListItem Value="1" Text="Yes"></asp:ListItem>
</asp:RadioButtonList>
<li id="shcompany">
<label for="txtCompanyName">Company Name</label>
<asp:TextBox runat="server" ID="txtCompanyName" CssClass="narrow" />
<label for="txtCompanyPhone">Company Phone Number</label>
<asp:TextBox runat="server" ID="txtCompanyPhone" CssClass="narrow" />
</li>
JS:
$(document).ready(function () {
var shcompany = $('#shcompany');
showHide();
mgift.change(function () {
showHide();
});
function showHide() {
var mgift = $('#rbMatchingGift');
var shcompany = $('#shcompany');
if (mgift.val() == "1") {
shcompany.show();
} else {
shcompany.hide();
}
}
});