An issue with IE (jQuery codes)
I have an issue with IE (I want to support IE users Grrrr):
$(function () {
var clonedField = $('.child').clone(),
main = $('.append');
$('', {
text: 'delete',
class: 'icon-delete',
href: '#',
click: functio开发者_开发知识库n () {
$(this).parent().remove();
return false;
}
}).appendTo(clonedField);
$('#add-input').click(function () {
main.append(clonedField.clone(true));
return false;
});
})
The error is: expected identifier, string or number
href: '#',
The problem is that IE treats "class" as a reserved keyword. Put it in quotes, like this:
text: 'delete',
'class': 'icon-delete',
href: '#',
This is actually stated on the $.attr reference page.
精彩评论