Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.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
如何在jquery中将AD添加到我的网格中_Jquery - Fatal编程技术网

如何在jquery中将AD添加到我的网格中

如何在jquery中将AD添加到我的网格中,jquery,Jquery,我在jquery中有这样的网格 success: function(result) { $('#MyGrid tbody').append('<tr><td>' + result.FileName + '</a></td><td><a href="#" class="remove">Remove</a></td></tr>'); } 成功:函数(结果){ $(“#MyGrid t

我在jquery中有这样的网格

success: function(result) {
    $('#MyGrid tbody').append('<tr><td>' + result.FileName + '</a></td><td><a href="#" class="remove">Remove</a></td></tr>');
}
成功:函数(结果){
$(“#MyGrid tbody”).append(“”+result.FileName+“”);
}
现在我想把thead添加到我的网格中,我需要在其中添加style属性,在thead中我还需要添加tr-having style属性。差不多

 <thead style=""><tr style=""></tr></thead>

通过jquery

我还需要删除另一个jquery函数中的thead。所以,您能告诉我如何在jquery中添加和删除包含tr的thead吗

谢谢,
michaeld

以下是如何创建
thead

$('#MyGrid').append(
    $('<thead />').addClass('headerrow').append(
        $('<tr />').addClass('grouprow')
    )
)

thnx eric,但是我没有得到“your and go”属性和它们的值。tr也在thead内吗?tr在thead内。
your
go
属性显示了css属性的去向。我已经编辑了我的答案实际上我已经修改成这样了,我所拥有的是你可以修改答案来得到这个。thnx@michael:
styleclass
不是有效的HTML属性。。。您的意思是
class
?是的,仅类属性采用字符串类型。sry for typo error空样式属性的作用是什么?您可以在我的tbody中看到我已删除,因此单击“删除”后,我不希望添加样式,这就是原因!我搞不懂你在想说什么。你知道
是一样的,对吗?
$('#MyGrid thead').hide();
function addtHead(table){
    var thead = jQuery("<thead></thead>");
    thead.attr('style','<your style goes here>');
    thead.attr('id', 'thead');
    var tr = jQuery("<tr></tr>");
    /*......Add columns here.........*/
    thead.append(tr);
    table.append(thead);
}

function removeThead(table){
    table.find('thead').remove();
}
success: function(result) {

  $('#MyGrid tbody').append('<tr><td>' + result.FileName + '</a></td><td>
}
/*.. where you need to remove the thead...*/
removeThead($('#MyGrid tbody'));