0

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');

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes it worked! ,this is my first stack overflow question and I look stupid now asking such question,anyway thanks for your help
@user1295276: you didn't look stupid at all. You asked the question in a clear and reasonable way (which is not so standard). Nothing wrong in asking.
0

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

2 Comments

yeah thanks,I've realized that ,I am new to stack overflow is there a way to show that a question is resolved?
click on check box outline you see left of the answer you accept

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.