我想不通为什么attr()
不起作用,但getAttribute()
呢。有人可以告诉我为什么我面临这个问题吗?下面是代码:为什么不.attr工作,但.getAttributes呢?
$('#assignAssetBtn').on('click', function() {
tableTools = $('#Grid').DataTable();
$.each(tableTools.$('td input', { 'filter' : 'applied' }), function (idx, data) {
// $.each(tableTools.fnGetSelectedData(), function (idx, data) { // this was not working so I changed the code a little bit
if (this.checked == true) {
debugger;
assetList.push({
'id': data.value,
'name': (data).getAttribute('name')
});
}
});
});
$('#assignAssetBtn').on('click', function() {
tableTools = $('#Grid').DataTable();
$.each(tableTools.$('td input', { 'filter' : 'applied' }), function (idx, data) {
// $.each(tableTools.fnGetSelectedData(), function (idx, data) { // this was not working so I changed the code a little bit
if (this.checked == true) {
debugger;
assetList.push({
'id': data.value,
'name': $(data).attr('name')
});
}
});
});
我与$(数据)尝试过,但不工作
你在'(data)'前面缺少'$'' –
@ArunPJohny我试过这个。这不起作用。 – Garden
你可以把你的代码与你尝试过的attr语法结合吗? –