Hi im working on javascript chat and i want to append data to conversation that it belongs to i have function to create new window and im setting a data attribute to each chat div
newWindow: function(name, id) {
if(!pushChatToArray(removeWhiteSpace(name))) return;
var div = htmlStructure(removeWhiteSpace(name));
setName(div, name);
setDataAttribute(div,"open","active");
setDataAttribute(div, "id", id);
$("body").append(div);
setCoordinates(div);
},
im creating new windows like this
chatbox.newWindow("USERNAME", "28");
all i want is select the specific chat div by the data atribute id
this code im using when im writing somebody that i have focused,so i can get the id by selecting the div like this :
var id = $(this).closest(".chat").data("id");
but i want to find chat with specific id like this
var chatid = $("body").find(".chat[data-id=1]");
Thank you for help