我从jQuery 1.6(无法记住确切版本)迁移到了jQuery 3.3.1,但在以下代码中出现错误:
//datatable row click events
$('#@mainDatatableName tbody').on('click', 'tr', function () {
checkForChange('#details-box', function () {
//this will enable details refresh
$('#detailsTab1 #Id').val(0);
debugger
//force active detail to reload
$('a[data-target=' + currentActiveTabContentId + ']').click();
});
});
语法错误通常如下所示:
jquery-3.3.1.js:1541 Uncaught Error: Syntax error, unrecognized expression: a[data-target=#detailsTab1]
at Function.Sizzle.error (jquery-3.3.1.js:1541)
at Sizzle.tokenize (jquery-3.3.1.js:2193)
at Sizzle.select (jquery-3.3.1.js:2620)
at Function.Sizzle [as find] (jquery-3.3.1.js:845)
at jQuery.fn.init.find (jquery-3.3.1.js:2873)
at new jQuery.fn.init (jquery-3.3.1.js:2983)
at jQuery (jquery-3.3.1.js:139)
at UsersAdmin:1696
at checkForChange (domis.common.js:43)
at HTMLTableRowElement.<anonymous> (UsersAdmin:1693)
我不明白为什么会出现这个错误。在之前的jQuery版本中没有显示此错误,代码也可以正常工作。是新版本jQuery语法发生了变化还是其他原因导致的呢?