Home > Article > Web Front-end > jquery method of splitting string_jquery
The example in this article describes how jquery splits strings. Share it with everyone for your reference. The details are as follows:
1. Question:
The returned data is a string separated by the special character @sss@vvv. How to return it to 2 IDs
$("#a").text(data)
$("#b").text(data)
How to make them display at the same time, corresponding to the two parts of the string, a corresponds to sss, b corresponds to vvv
2. Solution:
var arr = 'sss@vvv'.split('@'); $("#a").text(arr[0]); $("#b").text(arr[1]);
I hope this article will be helpful to everyone’s jQuery programming.