each

Get position of each element

扶醉桌前 提交于 2020-01-06 13:51:55
问题 $(function(){ var $animatedEls = $(".marked"); $(window).scroll(function(e) { var offset = 0; $.each($animatedEls, function(i, item) { offset = $(item).offset().top; console.log($(item).offset()); }); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h2 class="marked">This sucks.</h2> <div>...</div> <h2 class="marked">This sucks.</h2> <div>...</div> <h2 class="marked">This sucks.</h2> <div>...</div> <h2 class="marked">This sucks.</h2> <div>...<

jquery的each和js原生for循环性能对比

扶醉桌前 提交于 2020-01-06 04:42:30
[html] view plain copy < html xmlns= "http://www.w3.org/1999/xhtml" > < head runat= "server" > < title >for与each性能比较 </ title > < script src= "../Cks/jquery-1.7.1.min.js" type= "text/javascript" > </ script > < script type= "text/javascript" language= "javascript" > function getSelectLength() { var time1 = new Date().getTime(); var len = $("#select_test").find("option").length; var selectObj = $("#select_test"); for (var i = 0; i < len; i++) { if (selectObj.get(0).options[i] .text == "111111") { selectObj.get(0).options[i] .selected = true; break; } } var time2 = new Date().getTime(); alert(

using .each to execute array of functions on .resize

浪尽此生 提交于 2020-01-06 04:30:09
问题 In the an object called Response this works to trigger a function on .ready and .resize simultaneously... Response.action = function ( func ) { if ( typeof func !== 'function' ) { return false; } // If func is not a function, return false. $(function () { func(); $(window).resize( func ); }); // return func; }; // Response.action ...using this to call it: Response.action( myfunc ); function myfunc() { //do stuff } (We worked that out in this thread.) I'd like to make another version that can

Parser in Ruby: #slice! inside #each_with_index = missing element

强颜欢笑 提交于 2020-01-06 02:40:05
问题 Let's say, I want to separate certain combinations of elements from an array. For example data = %w{ start before rgb 255 255 255 between hex FFFFFF after end } rgb, hex = [], [] data.each_with_index do |v,i| p [i,v] case v.downcase when 'rgb' then rgb = data.slice! i,4 when 'hex' then hex = data.slice! i,2 end end pp [rgb, hex, data] # >> [0, "start"] # >> [1, "before"] # >> [2, "rgb"] # >> [3, "hex"] # >> [4, "end"] # >> [["rgb", "255", "255", "255"], # >> ["hex", "FFFFFF"], # >> ["start",

how to move files to different folders , based on matching filename and foldername in ssis

非 Y 不嫁゛ 提交于 2020-01-05 08:57:32
问题 I have four files xxxxxxCd999, xxxxCf999, xxxxC999 , xxxxD999 ... I need to move these files to their respective folders based on file name , for example file xxxxxCd999 should be moved to folder Cd999 , file xxxxCf999 should be moved to folder Cf999 ,file xxxC999 should ne moved to folder C999 so on ... How do I achieve this in ssis ? I have used a for each loop container, assigned some variables for sourcepath, destinationpath , and a file system task to use these variables , but im lost

jquery waiting for .ajax() to complete within .each() iteration

♀尐吖头ヾ 提交于 2020-01-05 06:49:25
问题 Ive a jquery function that obtains text from all nodes of a particular class using the jquery .each() selector: function get_text() { $(".my_class").each(function () { $this = $(this); node_text = $this.text(); console.log(node_text); }) } That works as expected. Next, I want to send the text to a php script using .ajax() : function get_php_text(node_text) { let url = `myphp.php?string_text=${node_text}`; $.ajax( { url: url, success: function(result) { console.log(result); } }); } That

How to get $values of Array in SCSS?

我只是一个虾纸丫 提交于 2020-01-05 04:30:06
问题 I'm making my own plugins that makes multiple media queries automatically by writing single @include line in SCSS. So when I type @include medias($bp-values, width); , the output should be like this: @media all and (min-width: 564px) { width: 200px; } @media all and (min-width: 768px) { width: 300px; } @media all and (min-width: 992px) { width: 400px; } @media all and (min-width: 1200px) { width: 500px; } And this is the code: $breakpoints: ( 564, 768, 992, 1200 ); $bp-values: ( width: (

How to re-create (each time create new) array in Ruby?

烈酒焚心 提交于 2020-01-05 03:07:33
问题 What I missing for create new array for each pair of numbers and then put the sum of each pair? Btw, is it possible to enter pair of numbers through ',' on one line? arr = [] sum = 0 puts "How much pair of numbers do you want to sum?" iter = gets.to_i iter.times do |n| puts "Enter pair of numbers: " a = gets.to_i b = gets.to_i arr << a arr << b end iter.times do |n| puts "Here are the sums: " arr.each { |x| sum += x } puts sum end The input must be like this: 2 # Number of pairs 562 -881 #

jQuery removing an element and renumbering remaining elements

前提是你 提交于 2020-01-04 09:16:29
问题 Does anyone see the flaw in my code here, because this one has me stumped! function removeMLRow(rowNo) { $('#ml_organize li:eq(' + (rowNo - 1) + ')').remove(); $($('#ml_organize li:eq(' + (rowNo) + ')').get().reverse()).each(function() { var newID = 'li' + ($(this).index() - 1); $(this).attr('id',newID); }); } 回答1: I can't say for sure based on the question, but I think this is what you're after: function removeMLRow(rowNo) { $('#ml_organize li').eq(rowNo - 1).remove(); $('#ml_organize li')

r mutate_each function is deprecated

送分小仙女□ 提交于 2020-01-04 02:03:18
问题 I use the function mutate_each from the tidyverse package and I get a message this function is deprecated. I would like to use the other functions that are not deprecated to change field types. Below is a reproducible example of how I currently employ mutate_each. library(tidyverse) set.seed(123) df <- data.frame(FirstName = sample(LETTERS[1:2],size=3, replace=TRUE), LastName = sample(LETTERS[3:6],size=3, replace=TRUE), StartDate = c("1/31/2000","2/1/2000","3/1/2000"), EndDate = c("1/31/2010"