Jquery, addclass to created element

Home / Uncategorized / Jquery, addclass to created element

I am using jQuery to dynamically build the column header for fullcalendar.js. This code is working but I want to be able to add a class name to each of the elements.
function buildDateColumnHeader(theDate) {
var container = document.createElement(‘div’);
var DDD = document.createElement(‘span’);
var ddMMM = document.createElement(‘span’);
DD.textContent = theDate.format(‘DD’).toUpperCase();
ddd.textContent = theDate.format(‘ddd’);

return container;
I have tried the following and they produce errors:DDD.classname = "ds-header-day";

var DDD = document.createElement(‘span’).addClass(‘ds-header-day’);
This is probably easy for a jquery savvy person.

There is a syntax error in your statement, hope that is not causing problems

It should be `DDD.className=’yourclass’
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *