javascript - jQuery .first() – does not work with IE? -


the following code adds cell radiobutton each row of table , checks first one:

$(document).ready(function () {     $('tr').prepend('<td>');     $('<input name="delete" type="radio"/>')         .prependto('tbody td:first-child')         .first().attr('checked', true); }); 

it not check first radiobutton ie 11, jquery-2.1.4 works firefox, chrome , ms edge; function last() works ie in case expected. bug?

you settings checked attribute "true" instead of "checked", works browsers choose inpret value means "checked". also, attribute initial value of input, doesn't work after element created.

you want set current value instead of initial value, checked property instead of checked attribute. use prop method set checked property true:

$(document).ready(function () {     $('tr').prepend('<td>');     $('<input name="delete" type="radio"/>')         .prependto('tbody td:first-child')         .first().prop('checked', true); }); 

Comments