Monday 5 March 2012

JQuery check/uncheck checkbox not working in IE7

I dynamically create a checkbox using JQuery as seen below:
$('').attr('type', 'checkbox').attr('class', 'myclass').attr('checked', true).appendTo(myContainerElement)
The problem is this doesn't work in IE7. The reason being you can't assign a type after the control is created. So I moved the type into the selection as can be seen below and this fixed my IE7 issue.
$('').attr('class', 'myclass').attr('checked', true).appendTo(myContainerElement)

No comments: