我对div的内容有疑问:
//d = document.getElementsByClassName("myclass")
//R = is an array and contains 'question' and other words
//d[u].innerHTML = 'Hi, this is a question'
//R[i] = 'question'
var inner = d[u].innerHTML;
alert(inner.indexOf(R[i]));//result -1
alert(inner.includes(R[i]));//result false
为什么我看不到正面回复?
编辑:
var inner = d[u].innerHTML;
alert(R[i]);//this alert is: question
alert(inner.indexOf('question'));//result >-1
alert(inner.includes('question'));//result true
现在正在工作,但我丢失了我的阵列...我该如何解决? 显然是indexOf并且包括不想变量????
编辑: 问题是R [i]值:
if R[i] = id="05" : error(indexOf -1); if R[i] = id=05 : correct (indexOf > -1);
但我必须使用""或者'',这是非常重要的,我该如何解决这个问题?