简体   繁体   中英

Set background colour to Input box in SAPUI5

I'm trying to change the colour entire input of sap.m.Input . Since it is having place holder & inner only border colour is changing.

document.getElementById("loginuser-placeholder").style.backgroundColor = "#232055 !important";
document.getElementById("loginuser-inner").style.backgroundColor = "#232055 !important";

This is how I tried forcing the elements to change its colour.

I also tried this:

var loginuser = new sap.m.Input("loginuser",{placeholder:"Username"});
loginuser.addStyleClass(".loginuser{background-color:#232055 !important }");
        

https://i.stack.imgur.com/uMTzb.jpg

When setting multiple values with JavaScript, it is not possible to do it in one, you need to call document.getElementById multiple times, like this:

function myFunction(){
    document.getElementById("div1").style.backgroundColor = "blue"
    document.getElementById("div1").style.backgroundColor = "!important"
}

not

function myFunction(){
    document.getElementById("div1").style.backgroundColor = "blue !important"
}

If you want to use a class, all you need to do is

oInput.addStyleClass("loginInput")

and in your css file you will add the style

.sapMInput.loginInput { color: blue; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM