each

Using jQuery each to replace image source

时光毁灭记忆、已成空白 提交于 2019-12-08 04:53:05
问题 I have the following issue. On load I want to use each to go through all the divs with the ".image" class, get the source of the image in that div and replace the source of the corresponding list item. Example below: useThis1 will replace the source of item1, useThis2 will replace the source of item2, so on and so forth. Any help on this would be much appreciated. <div class="image"><img src="useThis1"/></div> <div class="image"><img src="useThis2"/></div> <div class="image"><img src=

How to iterate over each select element in a dynamic form

北城余情 提交于 2019-12-08 03:03:55
问题 I saw this post for cloning form fields with incrementing ids - works great. But, in my adaptation, I have added a select box in the cloned form. The select box's id increments as it should. The goal is that when a particular choice (always the same in every cloned field) is selected, some hidden inputs are revealed. I can do this with javascript for a set # of known select elements, but I can't figure out how to iterate of each cloned select , since the user can create as many as they need?

python脚本编程——将批量的长方形图片切割成多个正方形图片

被刻印的时光 ゝ 提交于 2019-12-08 02:46:37
简介 在处理.mat文件得到图片(bmp)时,转成的图片尺寸大小与.mat文件有关。两个特征的.mat文件分别是1294*86和1294*128大小。这也是两个文件中的图片大小,由于模型输入需要的是批量的正方形图片,因此用python写脚本来将批量的长方形图片切割成多个正方形图片,并保存在相应文件夹中。 写代码 以1294*128尺寸的图像为例,需要的是128*128的正方形图像。 1)也就是说首先是将1294*128的尺寸处理成1280*128的尺寸,再将1280*128尺寸的图片切割成10个128*128的正方形图片即可。 这是存放图片的文件夹 其中一张图片的尺寸可以看到是1294*128。 首先将1294*128的图片剪裁成1280*128大小。 代码如下: # -*- coding: utf-8 -*- # 默认当图片宽度大于高度时,将图片批量处理成高度*高度的最大整数倍的大小 # 例如,将1294*128的图片剪裁成1280*128的大小的图片 import os,sys from PIL import Image import numpy as np import matplotlib.pyplot as plt import os folder = r'/Users/hjy/Desktop/blues' path = os.listdir(folder) #print

Scope of jQuery each() function?

我怕爱的太早我们不能终老 提交于 2019-12-07 18:06:26
I'm working with the jQuery ColorPicker widget - specifically exercising the ColorPickerSetColor function (just 'setColor' internally). Code excerpt: 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 { return this; } return this.each(function(){ if ($(this).data('colorpickerId')) { var cal = $('#' + $(this).data('colorpickerId')); cal.data('colorpicker').color = col;

Sum values in jQuery object by key

六月ゝ 毕业季﹏ 提交于 2019-12-07 17:07:11
问题 I have a csv file converted to a jQuery object using jQuery CSV (https://github.com/evanplaice/jquery-csv/). Here is the code for that: $.ajax({ type: "GET", url: "/path/myfile.csv", dataType: "text", success: function(data) { // once loaded, parse the file and split out into data objects // we are using jQuery CSV to do this (https://github.com/evanplaice/jquery-csv/) var data = $.csv.toObjects(data); }); I need to sum up values by key in the object. Specifically, I need to add up the

ACM常用技巧之尺取法--POJ3061/3320/2739/2100

人盡茶涼 提交于 2019-12-07 10:18:47
尺取法:反复推进区间的开头和结尾,来求取满足条件的最小区间的方法 。 《挑战程序设计》P146 POJ3061 Subsequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15988 Accepted: 6774 Description A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal length of the subsequence of consecutive elements of the sequence, the sum of which is greater than or equal to S. Input The first line is the number of test cases. For each test case the program has to read the numbers N and S, separated by an interval,

How to set itemController in each as (ember 1.11 beta3)?

拈花ヽ惹草 提交于 2019-12-07 04:38:26
问题 I want to try use: {{#each content as |product index|}} {{index}} {{/each}} But my app has the itemContoller, like this: {{#each product in content itemController='product'}} If I set this: {{#each content as |product index| itemController='product'}} It doesn't work! I found all of the ember guides and did not find the answer. Any help please. 回答1: Controllers ( Object , Array and itemController ) are going away. The new way to do things is by using a component. So, instead of your item

jQuery promise in function with each()

て烟熏妆下的殇ゞ 提交于 2019-12-07 03:24:12
问题 I'm tryin to call a own function and wait until its finishes. After the transitions end I want to start the next function. please have a look in my jsfiddle http://jsfiddle.net/hrm6w/ The console.log("upper finished") should start after console.log("promise finished") and all animations have ended. And after all animations in the each-Object have ended I want to start the next actions(functions). I think the promise()-function is all I need, but I just doesn't get this working. Any help would

JQuery: Help using .each() and .append() to add pictures to HTML

女生的网名这么多〃 提交于 2019-12-07 01:09:41
问题 Simple bug that needs to be fixed and I can't figure out what's wrong. I need to append the same picture to multiple (five) divs in the HTML. For some reason, my code is appending the same picture five times to each div. Making it more clear, each of the five divs needs one picture. Right now, all five have five pictures each. Here is the JQUERY: $(".faq").each(function(){ $('.faq .letter-q').append('<img src="images/faq-q.png" alt="Question">'); }); This is where it is being inserted: <div

Populating Next Right Pointers in Each Node 2

心已入冬 提交于 2019-12-06 21:59:32
描述:   给定一个二叉树 struct Node { int val; Node *left; Node *right; Node *next; } 填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL。 初始状态下,所有 next 指针都被设置为 NULL。 解答:   本题相较于上一题,缺少了要操作的树为完全二叉树的条件。因此在寻找同一层次上的next节点时候,节点不一定仅仅 存在于当前的节点的cur->next->left或者是cur->right的位置,这两个位置现在都可能为空,因此可能要在一层上一直向右 寻找第一个next节点。具体的递归代码如下:    class Solution { public: Node* connect(Node* root) { if (!root) return NULL; Node *p = root->next; while (p) {//向右一直寻找到第一个next节点 if (p->left) { p = p->left; break; } if (p->right) { p = p->right; break; } p = p->next; } if (root->right) root->right->next = p; if (root->left)