Whenver I put a
after the first line, the geocoding won't return any results. But when I remove it and have the address as one line, the geocoder works perfectly. I had thought innerText did not account for HTML such as (br />. Is there anyway to make it so it skips over the line break?
Thanks
P.S. I know my line breaks have parantheses at the beginning, but its because my post wasnt recognizing the HTML line break.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
正如您所说,.innerText 不返回换行标记(br),但它返回换行符(\n)。
简单的解决方案(用空格替换):
编辑,
.replace() 是字符串对象上的方法,它采用正则表达式作为第一个参数。 “g”代表全局,这意味着它应该替换所有出现的\n。如果没有它,只有第一个出现的地方会被替换。第二个参数是替换字符串。
.innerText does not return a linebreak-tag (br), as you say, but it returns a newline character (\n).
Simple solution (replace it with a blank space):
Edit,
.replace() is a method on the string object, which takes a regular expression as a first parameter. The 'g' stands for global, which means it should replace all occurrences of \n. Without it, only the first occurrence would be replaced. The second parameter is the substitute string.