jquery's method for splitting strings
- 2020-06-19 09:43:47
- OfStack
This article gives an example of how jquery splits strings. Share to everybody for everybody reference. The details are as follows:
1. The question is:
The data that is returned is a string that is split by the special character @sss @vvv, how do I return it to 2 id
$("#a").text(data)
$("#b").text(data)
How do you get them to show both parts of the string a for sss and b for vvv
2. Solutions:
var arr = 'sss@vvv'.split('@');
$("#a").text(arr[0]);
$("#b").text(arr[1]);
I hope this article has been helpful in your jQuery programming.