js文件中:
var executors_name = $("#executors_name") ;
var executors_name_val = executors_name.val();if(executors_name_val.indexOf("、") > 0){
executors_name.val(executors_name_val.substring(0,executors_name_val.length-1)) ;
}
报错:在红色一行 Cannot call method 'indexOf' of undefined
原因:<input type="text" name="executors_name" id="executors_name" />没有这一行,导致executors_name_val 的值为undefined
解决: var executors_name = $("#executors_name") ;
var executors_name_val = executors_name.val() || ‘’;
if(executors_name_val.indexOf("、") > 0){
executors_name.val(executors_name_val.substring(0,executors_name_val.length-1)) ;
}