javascript - 如何从 jquery 中的字符串中删除第一个文本?

标签 javascript jquery string

var selectedCustomers = document.getElementById("hfCustomerID");

output :- "|1|2|3"

this is my hidden field in which pushed value stored.

values in hidden field are stored "|1|2|3" like this

because of this when string is split and pushed in array at index 0 = "" is stored.

how to check and remove First "|" from string in jquery before pushing it to array?

最佳答案

"|1|2|3".slice(1).split('|');

使用 slice() 删除第一个字符。

"|1|2|3".match(/[^|]/g);

或使用正则表达式

关于javascript - 如何从 jquery 中的字符串中删除第一个文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44176470/

相关文章:

java - 如何将字符串中的数字递增 1?

javascript - 如何找到在可放置的 div 上放置的 div 的索引

javascript - 使用ckeditor编辑时出现404错误

javascript - 在基于 ajax 的网站的动态加载内容上运行 javascript

javascript - 如何在 Javascript 中延迟 for 循环执行

arrays - 使用 Spring MVC 从 Jquery ajax 方法返回字符串数组

javascript - 大量的 onclick 元素...或者一些 jquery

javascript - 检索页面加载 Strope js 上的消息

javascript - 使用表单提交在表单中添加时,Bootstrap 动态表单字段不起作用

python - 如何将数组中的字符串拆分为两个新数组