简体   繁体   English

如何在dijit / form / TextBox中更改PlaceHolder的颜色?

[英]How to change the color of PlaceHolder in dijit/form/TextBox?

Im trying to assign the value to a placeHolder in dijit/form/textbox. 我试图将值分配给dijit / form / textbox中的placeHolder。 I have used it in declarative Way... 我以声明的方式使用它......

<input id="searchbox" name="searchbox" value=""
                data-dojo-type="dijit/form/TextBox"
                style="width: 9em; height: 1.4em;font-size:14px" 
                onKeyPress="sboxOnClick">

document.getElementById("searchbox").placeholder="<font color='grey' style='font-weight:bold'>search</font>";

But I'm getting the value as, <font color='grey' style='font-weight:bold'>search</font> 但我得到的值是, <font color='grey' style='font-weight:bold'>search</font>

Can anyone give me some suggestions/pointer on how to change the color of the placeHolder in dijit/form/TextBox 任何人都可以给我一些关于如何在dijit / form / TextBox中更改placeHolder颜色的建议/指针

CSS: CSS:

 ::-webkit-input-placeholder { /* WebKit browsers */ color: #909; } :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #909; opacity: 1; } ::-moz-placeholder { /* Mozilla Firefox 19+ */ color: #909; opacity: 1; } :-ms-input-placeholder { /* Internet Explorer 10+ */ color: #909; } 
 <input type="text" placeholder="Enter text Here" /> 

JSFiddle Demo JSFiddle演示

One solution is that you can change the .dijitPlaceHolder in the css themes. 一种解决方案是您可以在css主题中更改.dijitPlaceHolder。

In my case, as I am not allowed to change the css themes, a dirty workaround is implemented 在我的情况下,因为我不允许更改css主题,所以实现了一个肮脏的解决方法

    dojo.query('.dijitPlaceHolder').forEach(
        function(inputElem){
            inputElem.style.fontSize = "11px";
            inputElem.style.fontStyle = 'normal';
        }
    );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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