I have the following function which works fine in chrome:
function updateUserID(element) {
var username = $("#viewColTasks").val();
var currentEvent = window.event;
if (currentEvent.keyCode === 13){
if (username == ''){
$("#viewColTasks").attr("placeholder", "Please enter a valid username");
$("#viewColTasks").val("");
}
else{
var text = $(element).val();
changeUserTo = text;
socket.emit('getUserID', text);
$("#viewColTasks").attr("placeholder", "Viewing " + username + "'s work");
$("#viewColTasks").val("");
}
}
}
is this not supported in FF? I have been researching and it seems something in relation to using e as the event but I haven’t managed to get anything working on both chrome and firefox
Any ideas?
You’re using a non-standard (Microsoft) way of dealing with events, which relies on the event object being available as a global variable.
If you bind the listener properly, you’ll have both the event target (the
element) and the event object available in a different way. Since you’re using jQuery, you should be doing: