Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am wanting to change the css in jquery if a certain statement returns true. I have just been playing around without the statement but it doesn't seem to work. This is my js file:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
window.SFW = window.SFW || {};
window.SFW.urgentAlertsItem = {
customItemHtml: function (ctx) {


    var urgentAlertsItemHtml = "<div class='urgent'><h2 class='name'>" + ctx.CurrentItem.Title + "</h2>";
    urgentAlertsItemHtml += "<div class='note'>" + ctx.CurrentItem.Note+ "</div>";
    urgentAlertsItemHtml += "<div class='severity'>" + ctx.CurrentItem.Severity+ "</div>";
    urgentAlertsItemHtml += "<div class='profile'> <img src='" + ctx.CurrentItem.Profile+"' /></div>";
    urgentAlertsItemHtml += "<button class ='moreDet'>More Detail</button></div>";
    return urgentAlertsItemHtml;
}
};

// anonymous self-executing function to setup JSLink templates on page load..
(function () {
var overrideCtx = {};
overrideCtx.Templates = {};

overrideCtx.Templates.Header = "<div id='urg'>";
overrideCtx.Templates.Item = window.SFW.urgentAlertsItem.customItemHtml;
overrideCtx.Templates.Footer = "</div>";

overrideCtx.BaseViewID = 1;
overrideCtx.ListTemplateType = 100;

SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();


// JavaScript source code
$(document).ready(function () {


        $(".severity").css("color: blue"); 

});
share|improve this question

2 Answers 2

up vote 2 down vote accepted

The correct syntax is either

$(".severity").css({"color" : "blue"});

OR

$(".severity").css("color", "blue");

The first syntax is used mostly to edit multiple css properties (separated by comma).

Source

share|improve this answer

This is the correct syntax

$(".severity").css("color", "blue");
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.