Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 cookie,我需要提取它的值并在每个值上运行一个函数。不确定如何分隔这些值......所以这就是我正在使用的内容:
var cookie = [1,2,3], val = cookie.methodThatSplitsEachValueIntoASeparateObject; val.each(function(){ //I'm running on 1, 2, and 3! });
简单for循环:
for
for (var i = 0; i < cookie.length; i++) { var val = cookie[i]; // alert(val); }
jQueryeach()方法:
each()
$.each(cookie, function(i, val) { // alert(val); });
也许你遍历数组?
for(var i=0;i<cookies.length;i++) { //Create object from cookies[i] }
希望有帮助。