I have a SP app and one of functions is to change background color but the problem is that when I choose a color in drop down there's nothing happening.

<select id ="selectColor">

var opt = $("#selectColor");

$(document).ready(function () {
    $("#selectColor").change(function () {
        if ($(this).text == "blue") {
            document.body.style.backgroundColor = "blue";

It is failing here, ($(this).text == "blue"). JavaScript is case sensitive, blue != Blue. Either give your options values and evaluate the values, or do a to lower comparison.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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