Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果需要,Jquery将更改文本颜色_Javascript_Jquery - Fatal编程技术网

Javascript 如果需要,Jquery将更改文本颜色

Javascript 如果需要,Jquery将更改文本颜色,javascript,jquery,Javascript,Jquery,我想更改类状态的文本颜色 当文本数大于0时,我使用此代码,工作正常: $(document).ready(function () { $(".status").filter(function () { return $(this).html() > 0; }).parent().css('color', 'red'); }); 当文本出错时,如何生成蓝色文本?我试过了,但没用: return $(this).html() == "error"; 您可以使用jQueryA

我想更改类状态的文本颜色

当文本数大于0时,我使用此代码,工作正常:

$(document).ready(function () {
  $(".status").filter(function () {
    return $(this).html() > 0;
  }).parent().css('color', 'red');
});
当文本出错时,如何生成蓝色文本?我试过了,但没用:

return $(this).html() == "error";
您可以使用jQueryAPI验证输入是否为数字

$(document).ready(function () {
$(".status")
    .filter(function () {
    return $.isNumeric($(this).val());
})
.parent().css('color', 'blue');});
$document.readyfunction{ $.status.filterfunction{ 返回$this.text==错误; }.parent.css'color'、'blue'; };
这是你应该做的:

您需要从中获取所需的状态。对其进行修剪,使其不包含空格。这样你就可以比较错误和错误了

$document.readyfunction{ $.status.filterfunction{ 返回$this.text.trim==错误; }.parent.css'color'、'blue'; }; 父母亲 错误
尝试返回$this.text==错误;如果你的意思是文本会出错。如果它不起作用,它会做什么?不,什么?…@Zorken17我试过但不起作用…我有三种解决方案-当数字,数字和文本错误。。。我想在文本出错时更改颜色这将不起作用,因为$this.text中的字符串不等于error。尝试执行console.log$this.text==错误,您将得到false。