开发者

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

Line 142: 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜