Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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 &引用;添加行“;逻辑未按预期工作_Javascript_Jquery_Html - Fatal编程技术网

Javascript &引用;添加行“;逻辑未按预期工作

Javascript &引用;添加行“;逻辑未按预期工作,javascript,jquery,html,Javascript,Jquery,Html,我花了好几天的时间才想出下面的方法,现在我意识到它仍然不起作用。我的“添加行”按钮工作不正常。我错过了什么 领域 比较 价值 名称 年龄 性 等于 开始于 不等于 添加行 $('tableSearchMainAccount1 tr')。每个(函数(){ var td=“”; //用于跳过表格标题(如果有) if($(this).find(“td:first”).length>0){ $(this).find('option:selected')。每个(函数(){ td=td+$(this).

我花了好几天的时间才想出下面的方法,现在我意识到它仍然不起作用。我的“添加行”按钮工作不正常。我错过了什么


领域
比较
价值
名称
年龄
性
等于
开始于
不等于
添加行
$('tableSearchMainAccount1 tr')。每个(函数(){
var td=“”;
//用于跳过表格标题(如果有)
if($(this).find(“td:first”).length>0){
$(this).find('option:selected')。每个(函数(){
td=td+$(this).text()+',';
});
td=td+$(this.find('input').val();
过滤器[ctr]=td;
ctr+=1;
}
});
//警报(filt)//警报输出,如name、equals、ann、age、equals、11
$('#添加').live('单击',函数()){
var$lastTr=$('table tr:last');
console.log($lastTr);
$lastTr.clone().insertAfter($lastTr);
//从上一个tr中删除按钮,否则每一行都会有它。
$('添加',$lastTr)
.替换为(“删除行”);
});
$('.remove_row').live('click',function(){
$(this).closest('tr').remove();
});
更换

<table> 



从评论中的讨论来看,您似乎没有引用jQuery

将以下内容添加到
部分:

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js"></script>

什么坏了?你期望的是什么行为,你看到的是什么?可能是因为你的HTML中没有任何id或类名?这是什么?->#TableSearchMainAccount1无任何损坏。。它只是不起作用me@SyazriAris“没什么坏的…只是我没用”。。。什么?@SyazriAris你说它不起作用是什么意思?如果它没有损坏或表现不正常,我们将无法帮助您。你想让它做什么?
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js"></script>
<!DOCTYPE html>
<html>
    <head>
        <title>My jQuery Project</title>
        <script src="jquery-1.8.3.min.js"></script>
        <script src="scripts.js"></script>
    </head>
    <body>
        <table>...</table>
    </body>
</html>
$(document).ready(function(){
    /* Wrapping your code with a document-ready
       block will ensure that the DOM will be
       ready before your code runs
    */
});