<div class="form-group">
<label class="control-label col-md-2">信息添加</label>
<div class="col-md-10">
<div class="checkbox-list">
<label class="checkbox-inline">
<input type="checkbox" value="txtDate" id="txtDate"/>
当前日期
</label>
<label class="checkbox-inline">
<input type="checkbox" value="txtPM25" id="txtPM25" />
PM2.5
</label>
<label class="checkbox-inline">
<input type="checkbox" value="txtTemper" id="txtTemper" />
当前温度
</label>
</div>
</div>
</div>
全选复制放进笔记 $("#zTree-cab").bind("cabZtreeOnClick", function (event, node) {
_id = node.objID, _type = node.type, _name = encodeURI(node.name);
if (_id == undefined || _id == null)
_id = node.id;
if (_type == 'LED') {
$.ajax({
type: "Post",
dataType: "json",
url: "./BackHandler/DataManageHandler.ashx",
data: { page: "formledinfo", execute: "select", datas: _id },
beforeSend: function () {
Metronic.blockUI({
target: '#tab',
overlayColor: 'none',
animate: true
});
},
error: function (msg) {
alert("加载超时,可能网速比较慢!" + msg);
},
success: function (data) {
if (data!=null) {
for (var i = 0; i < data.length; i++) {
if (data[0].IsinputTxt) {
$("#txtTXT").attr("checked", true);
}
if (data[0].IsTemper) {
$("#txtTemper").attr("checked", true);
}
if (data[0].IsPM25) {
$("#txtPM25").attr("checked", true);
}
if (data[0].IsCurrentDate) {
$("#txtDate").attr("checked", true);
}
if (!data[0].BrightnessControl) {
$("#DisplayType0").val(0);
} else {
$("#DisplayType0").val(1);
}
$("#SlidingType").val(data[0].SlidingType);
if (!data[0].TemperatureSensor) {
$("#TemperatureSensor").val(0);
} else {
$("#TemperatureSensor").val(1);
}
$("#ip").val(data[0].VMSIP);
if (!data[0].Photocell) {
$("#Photocell").val(0);
}
else {
$("#Photocell").val(1);
}
}
}
}
});
}
});
看你用的jquery版本,如果是1.8.3版本的话是没问题的,不过高于这个的话(比如1.9.0)则会返回undefined,
具有true和false两个属性的属性最好用prop(),其他用attr();
顺便贴一下1.8.3版本和1.9.0版本attr的区别,希望能够帮到你(prop是一致的)
1.8.3 attr():
boolHook = {
get: function( elem, name ) {
// Align boolean attributes with corresponding properties
// Fall back to attribute presence where some booleans are not supported
var attrNode,
property = jQuery.prop( elem, name );
return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
name.toLowerCase() :
undefined;
}
}
1.9.0 attr():
boolHook = {
get: function( elem, name ) {
var
// Use .prop to determine if this attribute is understood as boolean
prop = jQuery.prop( elem, name ),
// Fetch it accordingly
attr = typeof prop === "boolean" && elem.getAttribute( name ),
detail = typeof prop === "boolean" ?
getSetInput && getSetAttribute ?
attr != null :
// oldIE fabricates an empty string for missing boolean attributes
// and conflates checked/selected into attroperties
ruseDefault.test( name ) ?
elem[ jQuery.camelCase( "default-" + name ) ] :
!!attr :
// fetch an attribute node for properties not recognized as boolean
elem.getAttributeNode( name );
return detail && detail.value !== false ?
name.toLowerCase() :
undefined;
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。