Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何选择阵列中所有中的所有第一个td_Javascript_Php_Jquery_Html_Arrays - Fatal编程技术网

Javascript 如何选择阵列中所有中的所有第一个td

Javascript 如何选择阵列中所有中的所有第一个td,javascript,php,jquery,html,arrays,Javascript,Php,Jquery,Html,Arrays,我需要将所有的行首先放入一个javascript数组,并检查数组中是否存在print元素 我可以知道如何使用jquery或javascript来实现这一点吗 我在这里创造了一个小提琴手 试一试 然后使用$.inArray进行测试 像 演示:试试- $("table tr :first-child") 使用JQuery,这应该是可行的 $("tr td:first-child") 这将获得您的第一个td,然后您可以使用它们做任何您想做的事情使用以下jQuery代码: $(document).r

我需要将所有的行首先放入一个javascript数组,并检查数组中是否存在print元素

我可以知道如何使用jquery或javascript来实现这一点吗

我在这里创造了一个小提琴手

试一试

然后使用$.inArray进行测试

演示:

试试-

$("table tr :first-child")

使用JQuery,这应该是可行的

$("tr td:first-child")

这将获得您的第一个td,然后您可以使用它们做任何您想做的事情

使用以下jQuery代码:

$(document).ready(function(){
  $("table tr").each(function(index,value){
     var val = $(this).find("td:first").text();
     alert(val);
  });
});
还包括jQuery库。

试试这个

$("table tr td:first-child").each(function(index,value){
     var val = $(this).text();
     alert(val);
});

你试过自己解决这个问题吗?请你提供你已经尝试过的任何代码?向你的主人鞠躬!!!在2分钟内,你给出了一个完整的解决方案,只需要2行代码。@Arun P tnx很多。但是我需要跳过第一排,把其他的都弄到。这是因为我在工作中定义了一个表头,需要跳过它。我现在在数组中得到的是[Appointment date,07/10/2013,08/10/2013,10/10/2013,11/10/2013]Mazraara,我认为在这种情况下,不需要对该代码进行任何更改,因为标题是一个字符串,并且不会与您交叉的日期匹配checking@Arun这是对还是错?var exists=$.inArray'08/10/2013',arr!=-1.我问你是否检查是否存在?@ArunPJohny你能回答这个问题吗?你需要包括jquery。
$("table tr :first-child")
$("tr td:first-child")
$(document).ready(function(){
  $("table tr").each(function(index,value){
     var val = $(this).find("td:first").text();
     alert(val);
  });
});
$("table tr td:first-child").each(function(index,value){
     var val = $(this).text();
     alert(val);
});