Adding data to new element:
var ComBox = $('<div></div>').addClass('commentBox');
$.data(ComBox, 'ChannelID', 5);
$('body').append(ComBox);
When trying to get the data, results in undefined..
var cID = $('.commentBox').data('ChannelID');
console.log('cID : '+cID );
Replace this:
With this:
It uses this function
Best practice note, you better prefix your jQuery object with $ meaning:
ComBox=>$comBox