Answer the question
In order to leave comments, you need to log in
How to check VUE innerText for null or ' '?
Hello. I want to check innerText for an empty value or zero, but something doesn't work for me. here is a piece of code.
color: function () {
axios.get('/show/' + this.site.site + '/getJson/1').then((response) => {
this.urldata = response.data;
for (let j = 0; j<this.$refs.tr.length; j++) {
for (let i = 1; i < this.$refs.tr[j].cells.length-1; i++) {
if (this.$refs.tr[j].cells[i].innerText === '') { //тут проверка, не работает почему-то
this.$refs.tr[j].cells[i + 1].bgColor = "#ffffff";
console.log('1');
this.errors.push('1');
}
else if (this.$refs.tr[j].cells[i].innerText === null) { //тут проверка, не работает почему-то
this.$refs.tr[j].cells[i + 1].bgColor = "#ffffff";
console.log('2');
this.errors.push('2');
}
else if (this.$refs.tr[j].cells[i].innerText > this.$refs.tr[j].cells[i + 1].innerText) {
this.$refs.tr[j].cells[i + 1].bgColor = "#dbfee1";
console.log(this.$refs.tr[j].cells[i + 1].innerText); //это выводит в браузер, см. на картинке
}
else if (this.$refs.tr[j].cells[i].innerText === this.$refs.tr[j].cells[i + 1].innerText) {
this.$refs.tr[j].cells[i + 1].bgColor = "#fcffce";
}
else {
this.$refs.tr[j].cells[i + 1].bgColor = "#fedbe5";
}
}
}
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question