总结一下Invalid left-hand side in assignment的报错问题.即左边的参数引用报错.如下图所示
根据字面意思定位错误代码如下:
var textMaxlent = document.getElementById("textarea").value.length;
if(textMaxlent < maxLenght && anchorNum = 1){
anchorNum ++;
if (textMaxlent >= maxLenght ) {
anchorNum = 0;
}
...
}
anchorNum = 1
的写法不正确.应该写为anchorNum == 1
.更改后不报错.程序运行正常,这种在判断操作符中就应该写判断语句,不能写成赋值语句;