Hi in my app i have a page with five sliders ..for each slider value i assigned a text , but i am unable to give color for the that text .code as below

$(document).on("pagecreate", function (e) {
    $(e.target).find(".slider").on("change", function () {
        sVal = $(this).val();
         if (sVal == 0) {
            $(this).closest("div").next('.sliderlabel').text('');
        }

        if (sVal == 1) {

            $(this).closest("div").next('.sliderlabel').text(' Disagree');
        }

        if (sVal == 2) {
            $(this).closest("div").next('.sliderlabel').text('Disagree');
        }

        if (sVal == 3) {
            $(this).closest("div").next('.sliderlabel').text('Neither agree nor disagree');
        }


        if (sVal == 4) {
            $(this).closest("div").next('.sliderlabel').text('Agree');
        }
        if (sVal == 5) {
            $(this).closest("div").next('.sliderlabel').text('Strongly Agree');
        }
    });

});

i want to set color for each text, any help is appreciated.

有帮助吗?

解决方案

Use .css() to apply styles to element

Try this below example code for all values

$(this).closest("div").next('.sliderlabel').text('Strongly Agree').css('color','white');
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top