在 jQuery 中使用新行
下面的代码从文本框中获取文本,用“,”分割,然后如果字数超过10,则通过ajax将其发送到php。我设计此代码是为了与条形码阅读器(setinterval...等)一起使用。现在的问题是,无法设置条形码阅读器在每次扫描条形码后留下逗号。它添加了换行符。
所以我们可以说 ids.val();是换行符分隔的单词。如何将它们转换为逗号分隔的单词?
The code below gets text from textbox,splits by ",", then if words count more than 10 sends it to php via ajax. I designed this code to work with barcode reader (setinterval... etc). Now the problem is, can't set barcode reader to leave comma after each scanned barcode. It adds line break.
So lets say ids.val(); is line break seperated words. How do I convert them into comma seperated words?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
and
代替逗号版本!请注意,您可能希望使用
\n
和\r\n
进行更改,因为某些浏览器将换行符实现为前者,而另一些浏览器则实现为后者。如果您想将所有换行符转换为逗号,请使用
Use
and
instead of the comma-versions! Note that you might want to vary with
\n
and\r\n
as some browsers implement a newline character as the former and some as the latter.If you would want to convert all newlines to comma's, then use