-1
function createChatbox (from) {
console.log(from); //from= Hola
var chatBoxId= from+ 'chatbox';
$('#privateChat').append('<div id="'+ chatBoxId +'" class="chatbox"></div>');
$('#' + chatBoxId).draggable({ handle: '.drag' });
$('#' + chatBoxId).append('<p id="titulo" class="drag">Chat privado con: '+ from +'</p> <div id="'+ from +'textchat" class="textchat"></div><form id="msgPrivate" onsubmit="return formSubmit('+ from +')"><input type="text" id="privateMsg" class="texto" required><input type="submit" class="boton" value="Enviar" class="btnLogIn" id="sendPrivate"> ');
}

function formSubmit (from) {
console.log("entro en formSubmit");
console.log("from es: " +from); //from= [object HTMLDivElement]
sendPrivateMessage(from);
return false;
}

当它转到 formSubmit('+ from +') 时,from 转换为 [object HTMLDivElement] 我如何从该对象获取数据?

4

1 回答 1

0

解决方案是这样的:

onsubmit="return formSubmit('+'\''+ from +'\''+')"

谢谢!

于 2013-01-11T23:11:58.563 回答