ASP.NET单选按钮jQuery处理(ASP.NET radio button jQuery handling)
我试图弄清楚为什么我的页面不会触发单选按钮更改事件。
这是我的脚本,它应该在选中单选按钮后显示div。
$("input[id$='radio1']").change(function () { if ($("input[id$=radio1]").is(':checked')) { $('#div1').removeClass('hidden'); } });
这段代码有什么问题?
I am trying to figure out why my page doesn't fire the radio button change event.
Here's the script I have for it, it's supposed to show a div once the radio button is checked.
$("input[id$='radio1']").change(function () { if ($("input[id$=radio1]").is(':checked')) { $('#div1').removeClass('hidden'); } });
what's wrong with this code?
更新时间:2023-03-22 18:03
最满意答案
$("input[id$='radio1']").change(function () { if ($(this).is(":checked")) { $("#div1").removeClass("hidden"); } });
$("input[id$='radio1']").change(function () { if ($(this).is(":checked")) { $("#div1").removeClass("hidden"); } });
相关问答
更多-
好吧,如果您有三个具有相同名称的单选按钮,那么当您在表单集合中返回值时,该键的值将是所选单选按钮的值。 这就是他们的工作方式。 它们使用与逻辑分组相同的名称,因此选择一个,取消选择前一个。 因此,如果您按名称标识组,则可以假设该值是所选单选按钮的值! 安德鲁 Well if you have three radio buttons all with the same name, then when you get the values back in the form collection, the val ...
-
$("input[id$='radio1']").change(function () { if ($(this).is(":checked")) { $("#div1").removeClass("hidden"); } }); $("input[id$='radio1']").change(function () { if ($(this).is(":checked")) { $("#div1").removeClass("hidden"); ...
-
List
lst ..它是List类型 将其更改为SortedList List lst.. It is of List type Change it to a SortedList -
为单选按钮添加一个标签 。 看到这个例子。 Add a label for the radio button. See this example.
-
您只需要绑定输入本身 $(document).ready(function () { $('#<%= rbRadioButton.ClientID %> input').change(function () { // The one that fires the event is always the // checked one; you don't need to test for this alert($(this).val()); } ...
-
从单选按钮asp.net c#mvc4中检索多个模型值(Retrieve multiple model values from radio button asp.net c# mvc4)[2023-01-01]
弄清楚,只是使用ajax从我的控制器获取一个字符串: jQuery的: var CustomerID = jQuery('#hdnCustomerID').val(); var CustomerName = null; $.ajax({ url: '/Customer/GetCustomerName', data: { id: CustomerID }, type: "GET", ... -
您无法通过更改代码隐藏中的名称值来解决此问题,这是ASP.NET的错误/功能。 相信我,我已经为你做了这个研究和腿部工作。 看这个 。 You can’t fix this by changing the name value in the code-behind, it’s a bug/feature of ASP.NET. Trust me, I’ve done the research and legwork on this one for you. Look this.
-
我想使用jquery在asp.net中验证单选按钮列表(I want to Validate Radio Button List in asp.net using jquery)[2022-10-15]
你的代码应该是这样的 $(function(){ $("#<%=btnSave.ClientID %>").click(function(){ var v=$("#<%=rdTax.ClientID %> input:checked").length; if(v==0) alert('Not checked any radio button'); }); }); 或者更好,你可以试试这个 $(function(){ ... -
你的代码: $('form').validate(); $('form').on('submit', function () { console.log($(this).validate()); console.log("valid: " + $(this).valid()); //return false; }); 您不需要提交处理程序。 jQuery Validate插件...... a)捕获提交按钮的click , b)捕获触发验证的其他鼠标事件, c)进行验证, d)如果 ...
-
在页面加载期间,您将buttonset属性分配给类型为tag : radio元素。 您的DOM不存在此类元素。 您需要将div要应用按钮组的目标。 简而言之,您在选择器中缺少'#' 。 $(function () { console.log("ready!"); alert("Hi!"); $("#radio").buttonset(); }); During page load, you are assigning ...