//Whether it is selected or not, verify that there is a selected return true, otherwise return false function mycheckbox() { var falg = 0; $("input[name='soft[]']:checkbox").each(function () { if ($( this).attr("checked")) { falg = 1; } }) if (falg > 0) return true; else return false; }
This is a pretty good method, bookmarked. The following function is a supplement to the above:
That's how it was originally written. How to write jq1.42. Secondly, it is recommended that your logic processing function mycheckbox() { var falg = 0; $("input[name='soft[]']:checkbox").each(function () { if ($(this).attr("checked")) { falg =1; return false; } }) if (falg > ; 0) return true; else return false; }
The following is a simple judgment jquery core judgment statement judgment statement
if($('input:checkbox').attr("checked")==true)
Everyone knows that in html, if a checkbox is checked, it is checked= "checked". But if we use jquery alert($("#id").attr("checked")), it will prompt you that it is true instead of checked So many friends judge if($("#id"). attr("checked")=="true") This is wrong. In fact, it should be if($("#id").attr("checked")==true)
The example includes Let’s take a look at a few functions.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn