Tag: 每个

如何使用jquery逐个显示和隐藏每个div

我想创建一个flash新闻标题。 但我不知道问题出在哪里! 🙁 (因为我是网页设计初学者:D) 所以… 我想创建一个标题的一部分,显示(淡入)一个标题和隐藏(fadeOut)延迟… 之后显示下一个标题……(在一个没有停止的循环中)! PLZ帮助我学习如何创建……:这些是我写的代码: This is news title 1 This is news title 2 This is news title 3 This is news title 4 This is news title 5 This is news title 6 This is news title 7 $(document).ready(function() { $(‘.news’).each(function(index) { $(this).fadeIn(‘slow’).delay(700).fadeOut(‘slow’); }); });

Jquery – 使用each()获取类元素的位置

我需要知道“猫头鹰项目活跃”的位置,我知道目前的位置是2.总共有3张照片。 如何使用Jquery .each()获取此“owl-item active”的位置? 我有这段代码,但找不到代码的方法告诉我这个“猫头鹰项目活跃”是在2号位置。 $(‘.owl-stage .owl-item’).each(function( index, currentElement ) { console.log( index+1 ); //console.log( $(currentElement).find(‘div.owl-item.active’) ); }); 有人能给我一个如何做到这一点的线索吗?

从jQuery .each()中的javascript对象中删除它

我从以下javascript对象中删除this (特定的“事件”)时遇到问题, this是来自jquery .each()循环。 weatherData: { “events”:{ “Birthday”:{ “type”:”Annual”, “date”:”20120523″, “weatherType”:”clouds”, “high”:”40″, “low”:”30″, “speed”:”15″, “direction”:”0″, “humidity”:”0″ }, “Move Out Day”:{ “type”:”One Time”, “date”:”20120601″, “weatherType”:”storm”, “high”:”80″, “low”:”76″, “speed”:”15″, “direction”:”56″, “humidity”:”100″ } }, “dates”:{ “default”:{ “type”:”clouds”, “high”:”40″, “low”:”30″, “speed”:”15″, “direction”:”0″, “humidity”:”0″ }, “20120521”:{ “type”:”clear”, “high”:”60″, “low”:”55″, “speed”:”10″, “direction”:”56″, “humidity”:”25″ } } } 这是.each()循环的缩小版本: $.each(weatherData.events, function(i){ if(this.type == […]

jQuery循环通过json?

我有一些看起来像这样的json( var data ): {“success”:”true”,”keywords”:[“firstkeyword”,”secondkeyword”]} 我试图使用此代码循环关键字: data.keywords.each(function(e){ $(‘#campaign_keywords’).append(“”+e+””); }); 但是我得到了错误 Uncaught TypeError: Object firstkeyword,secondkeyword has no method ‘each’

在jQuery中使用.each动态对象?

有很多问题似乎都在问这个问题,但最终他们想要的只是附加.click事件,而不是.each,因此所有人都普遍接受的答案包括$(“body”).on(“click”, “.selector”, function(){}); 这绝对不是我想要的。 我有一些生成的输入,我需要同时更改每个输入的值。 通常我会$(“.inputs”).each(function(){$(this).val(“new-value”)};或者沿着这些行的东西,但是,我不能因为动态方面。 那你怎么做$(“body”).on(“each”, “.inputs”, function(){}); ?

jQuery从另一个select中填充动态创建的选择框

我有一个表单,您可以通过jQuery动态添加新行。 它创造了很好的元素。 但是,我在新行上有一个选择框。 创建时,它是空的。 我需要从该类型(类)的第一个选择框填充它。 这是HTML … Select One VE-13475 VZ-61300 Select One VE-13475 VZ-61300 Select One 我需要添加从第一个选择到最后一个选择的2个选项。 添加它们应该没问题。 但我似乎无法从第一个选择框中获得选项列表。 到目前为止,我已经尝试过…… $(“.cyclePoSelect > option:first”).each(function() { alert(this.text + ‘ ‘ + this.value); }); 这只是给了我“选择一个”选项。 $(“.cyclePoSelect > option”).each(function() { alert(this.text + ‘ ‘ + this.value); }); 这给了我所有的选择,但是来自现有的选择框。 jsFiddle – http://jsfiddle.net/scott80109/tkok9vwy/

jquery .each()循环继续加载更多按钮?

我为我的数组制作了每个循环的jQuery,但是我想在第一次启动时加载6个项目,然后当我点击加载更多按钮时,它将显示7到13,依此类推。 我首先使用.slice()完成了6限制,但总是在加载更多按钮时失败,有人可以帮忙吗? 我的代码: function loadName(){ $.getJSON(‘/namedatabase.php’, function(data) { $.each($(data).slice(0, 6),function(i,item){ $(“.nameData”).append(”+item.name+”); }); }); } 加载更多按钮 Load more

每个内部都有jquery setTimeout

我有一些类似于此的代码,它在一些图像中移动……它可以工作,但它似乎不尊重计时器 var i = 1; var indexArray = array(1,2,3); var timerx = new Array(); $( indexArray ).each(function( indexArraykey ) { function internalCallback ( i, indexArraykey ) { val = indexArray[indexArraykey]; console.log(“test ” + i + val); }); timerx[i] = setTimeout( internalCallback( i, indexArraykey ), i * 500000 ); i++; });

jQuery的范围是each()函数吗?

我正在使用jQuery ColorPicker小部件 – 专门运用ColorPickerSetColor函数(内部只是’setColor’)。 代码摘录: setColor: function(col) { if (typeof col == ‘string’) { col = HexToHSB(col); } else if (col.r != undefined && col.g != undefined && col.b != undefined) { col = RGBToHSB(col); } else if (col.h != undefined && col.s != undefined && col.b != undefined) { col = fixHSB(col); } else […]

为什么$ .each()比jquery中的循环慢?

有些消息来源要求在jquery中使用“for loop over $ .each()” ,因为$ .each()比ops / sec中的循环要慢 这是因为$ .each()的回调函数吗? 任何人都可以解释为什么$ .each()比jquery中的循环慢,在这种情况下我必须选择循环超过$ .each()或反之 ? 提前致谢。