我正在使用jQuery 1.12。点击TD之后,我想删除其中除了“savedBlock”类之外的所有元素,所以我尝试了
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define maxLineLength 1000 //Maximum length of a line
#define wordsPerLine 200 //Maximum words in a line
#define maxLines 200 //Maximum lines in an input
int main(int argc, char *argv[])
{
char line[maxLineLength] = {0};
char *inputArray[maxLines][wordsPerLine] = {};
char *ptr, *token;
int i, j, lines, maxWords = 0;
FILE *inputFile = fopen("input.txt", "r");
if (inputFile)
{
i = j = 0;
while (fgets(line, maxLineLength, inputFile))
{
token = strtok(&line[0], ",\n");
while(token)
{
if(ptr = malloc(sizeof(char) * (strlen(token)+1))) //whether malloc succeeded
{
if(token[0] == ' ')
strcpy(ptr, token+1);
else
strcpy(ptr, token);
inputArray[i][j++] = ptr;
token = strtok(NULL, ",\n");
}
else
{
printf("malloc failed!\n");
exit(1);
}
}
if(maxWords < j)
maxWords = j;
i++;
j = 0;
}
lines = i;
fclose(inputFile);
for(i = 0; i < lines; i++)
{
for(j = 0; (j < maxWords) && inputArray[i][j]; j++)
printf("%s | ", inputArray[i][j]);
printf("\n");
}
}
return 0;
}
不幸的是,这有消除一切的效果。运行之后,至少一切都从表格单元格中消失了。如果我注释掉$(elt).closest('td').find('.savedBlock').show()
$(elt).closest('td').not('.savedBlock').remove()
行,则不会删除任何内容,但现在我看到的不仅仅是我想要的内容。有什么建议吗?
答案 0 :(得分:2)
试试这个:
$('td').on('click', function(e) {
$(this).children().not(".savedBlock").remove();
})
答案 1 :(得分:0)
$(elt).closest('td:not(.savedBlock)').remove()
答案 2 :(得分:0)
class Post(models.Model):
title = models.CharField(max_length=200)
tags = models.ManyToManyField(Tags)
slug = models.SlugField(max_length=200, blank=True)
creation_date = models.DateTimeField(auto_now_add=True)
modify_date = models.DateTimeField(auto_now=True)
content = models.TextField()
应该怎么做。冒号在不是
之前