I am currently working on calendar showing starting date and ending date of various projects in a hypothetical organisation, I have manage to do that using classes in javascript for each project
What I can't figure out is that :Is there to way to pass object values to .css() method in jQuery.
For example, can I do something like this :
$('this').css('background-color','object.colorCode');
You need to remove the quotation for the second argument there. I guess object
really is an object with the property colorCode
which hopefully contains a useful value.
Currently you're passing in the string-value "object.colorCode"
into the style, which obviously makes no sense at all.
Beyond that, $('this')
on the other hand should have no quotation. $(this)
please.
You should be able to pass in object.colorCode
without the quotes. Also $(this)
shouldn't have quotes either so the statement should be:
$(this).css('background-color', object.colorCode);
That is assuming colorCode
is a property of the object
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.