The data that is dynamically output on the page, this is the data that Ajax obtains I want to show on the page
Copy Code code as follows:
Success:function (data) {
var arr = Data.split ('_');
var Numarr = Arr[0].split (",");
var numstr = "";
if (numarr.length==undefined | | numarr.length==0) {
$ ("#phonenolist"). HTML (' Sorry, no query to the corresponding number! ');
}else{
for (Var i=0;i<numarr.length;i++) {
Numstr + = "<li><a id= ' N_" +i+ "href=\" Javascript:choose_mobile ("
+ numarr[i].tostring () + ", N_" +i+ "); \" class= ' Buy ' > "
+ numarr[i].tostring (). substring (0, 3)
+ "<span class= ' org ' >"
+ numarr[i].tostring (). SUBSTRING (3, 7) + ""
+ numarr[i].tostring (). substring (7, 11)
+ "</span></a></li>";
}
$ ("#phonenolist"). HTML (NUMSTR);
}
index = arr[1];
Total = arr[2];
$ ("#curr"). html (' +index+ ' page, total ' +total+ ' page ');
}
function Choose_mobile (num,id) {
Alert (num+ "" +id);
$ ("#mobile"). Val (num);
$ ("#xhmobile"). HTML ("$ ("#" +id). addclass ("buy")-siblings (). Removeclass ("buy");
}
In JS, my parameters are probably like this, Choose_mobile (number, object ID), but in the execution of JS only pop up the number, no ID, so I am very depressed, and then ask someone else, in the code 9th, 10 lines, to the method of two parameters with ' single quotes,
Copy Code code as follows:
Numstr + = "<li><a id= ' N_" +i+ "href=\" Javascript:choose_mobile (' "
+ numarr[i].tostring () + "', ' N_" +i+ "); \" class= ' Buy ' > "
So successful, before let me good entanglements, JS to string parsing with the number string parsing is still not the same ah, divided so clear