1

in my innerhtml, i have pass and fail and i want to add css properties for these.

function display()
{
    var a=document.getElementById("myList");
    var dropdownvalue = a.options [a.selectedIndex].text;
    var b=document.getElementById("myText").value;

    if(dropdownvalue == b.substring(0,4)) {
        document.getElementById("result").innerHTML = "Pass"; 
    } else {
        document.getElementById("result").innerHTML = "Fail";  
    }
}
2

1 Answer 1

2

you can use .style

if(dropdownvalue == b.substring(0,4)) {
        document.getElementById("result").innerHTML = "Pass"; 
        document.getElementById("result").style.color = "green";
     }
        else {
        document.getElementById("result").innerHTML=    "Fail";  
        document.getElementById("result").style.color = "red";
     }

Comment for any questions :)

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.