jQuery Checkbox dynamically created with checked property -


$('<input>', {     type: "checkbox",     id: "checkbox" + value.attributename,     name: "checkbox" + value.attributename,     classname: required + " " + datatype,     attributeid: value.attributeid,     disabled: readonly,     checked: (value.attributevalue != "0") ? "true" : "false" }).appendto(li); 

i dynamically creating checkbox element. need assign checked property or not. in code below, it's checked because property present.

help?

don't use string here, use boolean:

$('<input>', {     type: "checkbox",     id: "checkbox" + value.attributename,     name: "checkbox" + value.attributename,     classname: required + " " + datatype,     attributeid: value.attributeid,     disabled: readonly,     checked: (value.attributevalue != "0") }).appendto(li); 

checked boolean property in dom, string of non-0 length "truey", meaning "false" true. instead set directly true or false, no strings.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -