Tag: 循环

迭代jquery中的嵌套表单元素

我很抱歉,如果这已经发布我一直在寻找无济于事.. 我只是想知道如何在jquery中循环嵌套表单’elements’(元素不仅是输入标签之类的严格表单元素,还包括其他html元素)。 目前我有这段代码来做: $(‘#’+arguments[i].formid).children().each(function(){ var child = $(this); alert(child.attr(‘id’)); if(child.is(“:input”)) { alert(child.attr(‘id’)); if(child.attr(‘id’)!=”) eval(“p.”+child.attr(‘id’)+”='”+child.attr(‘value’)+”‘”); } if(child.is(“:textarea”)) { if(child.attr(‘id’)!=”) eval(“p.”+child.attr(‘id’)+”='”+child.attr(‘value’)+”‘”); } }); 当我的表单包含这样的其他元素时,它不起作用: … 请帮忙…

jQuery – 当鼠标hover在元素上时,如何继续动画?

我需要一种方法来执行某种’whileonmouseover’function,以便在鼠标覆盖元素时继续动画… 例如,给定此function: $(document).ready(function() { function doAlert() { alert(1); } $(‘#button’).hover(function() { doAlert(); }); }); 当鼠标hover在#button上时,警报将触发一次。 当鼠标停留在#button上时,我需要一种方法来继续发出警报 我已经尝试做某种函数递归来继续警报,直到设置一个触发器导致它停止: $(document).ready(function() { var doLoop = true; function doAlert() { if (!doLoop) return; alert(1); doAlert(); } $(‘#button’).hover(function() { doAlert(); }, function() { doLoop = false; }); }); 但那失败了。 似乎该函数完全忽略’hover off’中的’doLoop = false’赋值。 有没有办法实现这个目标?

在没有任何插件的jquery中可滚动,旋转木马,滑块 – 最简单的方法

我正在寻找有关循环动画的jQuery滑块(如可滚动插件)的教程。 没有任何插件,最简单的方法,教程

jquery循环来创建元素

到目前为止,我对这项任务没有运气,所以感谢任何帮助。 我有一个html表单,其中有一个小选择菜单(1-10)即 1 2 … 10 根据选择的值,我希望jquery创建(或删除)该数量的输入文本框(具有不同的名称和ID)。 例如,如果选择2,则会创建这些输入: 我期待您的简单而优雅的解决方案! 安迪

解析数据以创建导航窗格

我有这个XML响应: http : //jsfiddle.net/ZeeHv/ 我正在尝试使用转储中的信息创建这样的东西: Academic BM CMTTE DM PM ARCHIVE ASSOCIATIONS BM DM PM 最后,XML可以为我提供所有网站和子站的列表: https://hosted.demo.ca https://hosted.demo.ca/academic https://hosted.demo.ca/academic/bm https://hosted.demo.ca/academic/cmtte https://hosted.demo.ca/academic/dm https://hosted.demo.ca/academic/pm https://hosted.demo.ca/archive https://hosted.demo.ca/associations https://hosted.demo.ca/associations/bm https://hosted.demo.ca/associations/dm https://hosted.demo.ca/associations/pm 如何查看此信息并附加ul和li标签以创建网站导航菜单? JS过去常常得到XML: function getAllSites(){ $().SPServices({ operation: “GetAllSubWebCollection”, async: true, completefunc: function(xData, Status){ $(xData.responseXML).find(“Web”).each(function(){ console.log($(this).attr(“Url”)); }); } }); }

jQuery从列表中获取img源属性并推送到数组中

我有这个缩略图列表,并希望将图像路径(源)推送到一个数组:tn_array

使用javascript,jQuery启动和停止/暂停setInterval

我试图暂停,然后播放一个setInterval循环。 在我停止循环后, 我尝试的“开始”按钮似乎不起作用: HTML: JS: input = document.getElementById(“input”); function start() { add = setInterval(“input.value++”,1000); }start(); 有没有更好的/工作方式来做到这一点? 你可以自由使用jQuery。 谢谢!

将变量传递给$ .ajax()。done()

我迷路了。 我如何将循环变量传递给AJAX .done()调用? for (var i in obj) { $.ajax(/script/).done(function(data){ console.log(data); }); } 显然,如果我要做console.log(i+’ ‘+data) 我会在每次迭代时返回对象obj中的最后一个键。 文档让我失望。

带有setTimeout的递归JS函数

我有以下代码 var data = [ { id: “0” }, { id: “1”, children: [ { id: “1.1”, children: [ { id: “1.1.1”, children: [ { id: “1.1.1.1”, children: [ { id: “1.1.1.1.1” }, { id: “1.1.1.1.2” }, { id: “1.1.1.1.3” } ] }, { id: “1.1.1.2” }, { id: “1.1.1.3” } ] }, { id: […]

Javascript函数是在循环中使用最后已知的参数?

我有一种情况,我需要动态创建按钮,我需要将onclick事件附加到每个按钮。 以上所有都做得很好。 但是,当单击其中一个按钮时,调用的函数ie(animate(poly,map))使用poly的最后已知值和map作为参数。 从今天早上起我就遇到了这个问题。 请帮忙。 谢谢 for(var k=0;k<arr_altern.length;k++){ my_div=create_div_interchange(arr[i],1,78,visited_bus,interchange_arr,arr_altern[k],null, my_interchange_array); $('#results').append(my_div); var x='animate'; var v='#animater'; v+=div_id; x+=div_id; map=create_map(div_id); var poly=retrieve_results_edges(bus_stops_visited,map); var strVar=""; strVar += "”; strVar += “”; strVar += “”; $(v).append(strVar); document.getElementById(x).onclick=function test(){ animate(poly,map); } set_map(map); set_polyline_color(my_traversed_edge,map); } 更新解决方案: i’ve replaced document.getElementById(x).onclick=function test(){ animate(poly,map); } 通过 $(‘#’+x).bind(‘click’,{poly:poly,map:map}, function(event) { animate(event.data.poly,event.data.map) });