Cheerio
Cheerio

Reputation: 1240

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: function () {
            $(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: '#',

Upvotes: 1

Views: 77

Answers (1)

alexn
alexn

Reputation: 59002

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.

Upvotes: 5

Related Questions