Home  >  Article  >  Web Front-end  >  jquery下checked取值问题的解决方法_jquery

jquery下checked取值问题的解决方法_jquery

WBOY
WBOYOriginal
2016-05-16 17:51:011034browse

一怒之下,给checkbox加一个isCheck,,不用那该死的checked属性...一切OK了...代码如下:

复制代码 代码如下:




修复checkbox的状态切换和动态取值的问题







  • 美食1

  • 美食2

  • 美食3

  • 美食4

  • 美食5





<script> <BR>//修复checkbox的状态切换和动态取值的问题 <BR>//为checkbox新增一个isCheck属性来替换checked属性的不兼容性 <BR>$(".ckbox").click(function(){ <BR>if($(this).attr("isCheck") == "true") { <BR>$(this).removeAttr("isCheck") <BR>} else { <BR>$(this).attr("isCheck", "true"); <BR>} <BR>}) <BR>function getValues() <BR>{ <BR>var list=""; <BR>$(".ckbox").each(function(){ <BR>if($(this).attr("isCheck") == "true"){ <BR>list += $(this).val() + ","; <BR>} <BR>}) <BR>alert(list); <BR>} <BR></script>


Statement:
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