lundi 6 avril 2015

javascript unexpected token }

I have this block of code where I'm creating two link elements on a web page and adding a click event to them:



function createNewChat(){
//alert("new chat fired");
var roomName = document.getElementById("roomName").value
if (roomName){
resetErrorLog();
$('#createRoom').append('<p>would you like to password protect this room?</p>');
$('#createRoom').append('<div><a href="#" onclick="newChatHelper("yes")"> yes </a></div>');
$('#createRoom').append('<div><a href="#" onclick="newChatHelper("no")"> no </a></div>');
}
else {
document.getElementById("errorlog").innerHTML = "<p>The room name input box seems to be empty</p>";
}
}


The DOM updates properly, but when I click the link I get an unexpected token } on line 2, which is an tag. This block of code is much later in the file. The helper method isn't getting fired at all so I'm pretty sure that the problem is with this code. Help is much appreciated.





Aucun commentaire:

Enregistrer un commentaire