你能检查一下我的函数是否正确:
JS
$(eachsection).each(function() {
listfunction();
}
function listfunction(){
$(this).show();
$(this).find('a.q_weblinksprite_med').attr("onclick", construct_url);
$(this).find('.q_weblinksprite_med').text(itemTitle);
$(this).find(".status").text(itemStatus);
$(this).find('.q_rt_rowcell-1-title').text(itemCategory);
$(this).find('.q_clipline').html(itemContent);
}
我想要的只是从listfunction()
返回所有内容。谢谢!
答案 0 :(得分:1)
您发布的代码不会返回任何内容。
看起来,你可以返回一个数组
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#define PROGRAM_A "./loops"
int main(){
int nrOfProcesses = 1;
int i;
printf("How many processes you want to create?");
scanf("%d", &nrOfProcesses);
printf("You entered: %d\n", nrOfProcesses);
int processid;
for (i=0; i<nrOfProcesses; i++){
if((processid = fork()) == 0){
printf("PROCESS ID: %d\n", processid);
printf("My PID: %d\n", (int) getpid());
printf("Return value: %d\n", (int) processid);
exit(0); /* exit this (child) process */
}
}
while(wait(&i)>=0); /* get rid of the exited processes from the system */
scanf("%d", &nrOfProcesses);
printf("\nProcesses created!");
execlp(PROGRAM_A,PROGRAM_A,NULL);
return 0;
}
这是你在找什么?
答案 1 :(得分:0)
从你拥有它的位置调用listfunction(
)将导致你失去范围。因此,如果您尝试呼叫$(this).show()
并让它显示您循环播放的元素,则需要像这样调用它:
$(eachsection).each(function() {
listfunction(this);
}
function listfunction(element){
$(element).show();
$(element).find('a.q_weblinksprite_med').attr("onclick", construct_url);
$(element).find('.q_weblinksprite_med').text(itemTitle);
$(element).find(".status").text(itemStatus);
$(element).find('.q_rt_rowcell-1-title').text(itemCategory);
$(element).find('.q_clipline').html(itemContent);
}