【发布时间】:2018-10-25 16:55:00
【问题描述】:
我想要替换某些系统语言的页面上有以下脚本。
<script>
function xchangemessage2()
{
xval = jQuery('[ID*="_UserMessageText"]').html();
xvalpos = xval.indexOf("We could not find your information in our system. Please search again or contact us for assistance.");
xvallen = xval.length;
if (xvalpos > 0)
{
jQuery('[ID*="_UserMessageText"]').html(xval.substring(0, xvalpos+xvallen) + ' If you provided a valid user name, an email will be sent to the email address on file.')
}
}
Sys.Application.add_load(xchangemessage2);
</script>
我一直在努力
Javascript TypeError:无法读取未定义的属性“indexOf”。
【问题讨论】:
-
验证您有一个带有
id='_UserMessageText'的HTML元素。 -
在
xval = jQuery('[ID*="_UserMessageText"]').html();行之后执行console.log(xval )看看你得到了什么 -
如果选择器不匹配任何内容,
html()将返回undefined。 -
已经修复,请查看以下链接:[stackoverflow.com/questions/41895890/…
标签: javascript jquery