1

如何更改代码以适应 jquery 版本我的 jquery 版本是 v1.4.2。当我升级没有工作了。需要帮助来修复它。找到了 migrate.js 但不想使用它。这是我的代码:

$(document).ready(function () {
var mrTables = $(".mrQuestionTable");
/* var mrTables = $("table.mrQuestionTable"); in DC 7.0 is not a table */

mrTables.each(function () {
    var tbl = $(this);
    var tblTds = tbl.find("td");
    var isGrid = false;
    if (tblTds.eq(1).attr("class") != null ) {
        isGrid = tblTds.length > 1 &&  tblTds.eq(1).attr("class").indexOf("Grid") >= 0 ;
    }
    var tblInps = tbl.find('INPUT[type="checkbox"].mrMultiple');
    tblInps.each(function () {
        var inp = $(this);
        this.group = isGrid ?    /* group of checkboxes */
            inp.closest('tr').get(0) /* when is grid, group is closest row */
            : tbl.get(0);   /* else table */
        this.isNotMulti = inp.attr("name").indexOf("nmult") >= 0;
        inp.change(clearAnswers);   
    }
  );
});

});

这是 clearAnswers 函数:

function clearAnswers(e) {
var el = e.target;
if (!el.checked)
    return;
var inps = $(el.group).find('INPUT[type="checkbox"][group].mrMultiple');
    // when is grid uncheck only in the same row

inps.each(function () {
    //  if checked element is notMulti unckeck all else  uncheck all notMutli 
    if (this != el && (el.isNotMulti || this.isNotMulti))
        this.checked = false;
});

}

实际上, migrate.js 也没有工作

4

0 回答 0