如果文本框达到一定数量,如何更改它的背景颜色?

问题描述:

基本上标题,我希望文本框在0以上时为绿色,在0以下时为红色



我尝试了什么:



尝试做一个if语句,显然做错了。

Basically the title, I want the textbox to be green when above 0 and red when below 0

What I have tried:

Tried doing a if statement, apparently doing it wrong.

因为文本框中的文本可以从某处复制并使用鼠标粘贴,我会使用以下内容:



Because texts in the textbox can be copied from somewhere and pasted using the mouse, I would use the following:


#TextBoxID)。bind(' input propertychange' function (){
var textLen = this .value.length;

if (textLen> 0
// 使其绿色
else
// 将其设为红色
});
("#TextBoxID").bind('input propertychange', function () { var textLen = this.value.length; if(textLen > 0) //Make it green else //Make it Red });