André Figueira
André Figueira

Reputation: 6696

Getting an error on new event Unexpected token ILLEGAL

I am getting the following error:

Uncaught SyntaxError: Unexpected token ILLEGAL

and this is showing on line 1 of my page.

I am using the following code:

$('.hollaBackClick').live('click', function(){

    var currentElement = $(this);
    var hollaID = currentElement.attr('hollaID');
    var userID = currentElement.attr('userID');
    var username = currentElement.attr('username');

    var hollaBackBoxHTML = '<form id="hollaBackForm">' +
        '<input type="hidden" name="hollaID" value="' + hollaID + '" />' +
        '<input type="hidden" name="userID" value="' + userID + '" />' +
        '<input type="hidden" name="username" value="' + username + '" />' +
        '<textarea name="hollaBackContent" id="hollaBackContent" placeholder="HollardBack@' + username + '" />' +
        '<input type="submit" name="hollaBackSubmit" id="hollaBackSubmit" value="HollaBack" />' +
    '</form>';

    currentElement.after(hollaBackBoxHTML);

});

I am using click events all over the website and this is the only place I get the error and I am somewhat stumped into what could be causing the issue...

Upvotes: 0

Views: 254

Answers (2)

Andr&#233; Figueira
Andr&#233; Figueira

Reputation: 6696

I have solved the issue, I got confused and had two html elements with the same class one without the attributes. Changing the class solved the problem. So to confirm anyone else that has this issue make sure that your event is targeting the particular element you intend it for.

Thanks for you help guys!

Upvotes: 0

sujal
sujal

Reputation: 1050

currentElement.after(hollaBackBoxHTML);

are you trying to do like this?

Upvotes: 1

Related Questions