$(this).attr("checked") 为 undefined

在Jsp中去checkbox的选中与否:

        使用Jquery的attr方法:

          var selectStatus  =     $("#checkboxId").attr("checked");

        如果  selectStatus = true 则 为选中状态

        如果  selectStatus = false 则为为选中状态

 但是 有时:  selectStatus 为 undefined 

         此时需换一种取值方式:selectStatus = $("#checkboxId").prop("checked");

     具有 true 和 false 两个属性的属性,如 checked, selected 或者 disabled 使用prop(),其他的使用 attr()

猜你喜欢

转载自lihongtai.iteye.com/blog/2197132