select標籤:具有默認值 + 可以手動更改

從網上找代碼;
應用到項目中,發現能設置默認值,但是不能手動更改;
從w3c查找對應的使用方法,並且在它的界面中實踐;發現代碼無誤,觀察項目,發現很可能是其他的jquery限制了其不能手動更改。

於是,先找到能手動更改的部分,再把代碼放到這塊中。

/* 這裏是javascript 中的代碼 */
function CreateTableRow() {
    var TableRowIndex = ($('#grid_Condition tbody tr').length + 1);
    for (var i = 0; i < 5; i++) {
        var tr = '';
        tr += '<tr>';
        tr += '<td class="td-div" style="text-align: center;">' + TableRowIndex + '</td>'
        tr += '<td style="text-align: center;"><select id="Range➩' + TableRowIndex + '" class="txtselect" onchange=\"ChangeItem(' + TableRowIndex + ')\"><option value=""></option><option value="before"></option><option value="after"></option><option value="all">全部</option></select></td>'
        tr += '<td><input id="CharNum➩' + TableRowIndex + '" type="text" class="txt" /></td>'
        tr += '<td><input id="Expression➩' + TableRowIndex + '" type="text" class="txt" /></td>'
        tr += '<td style="text-align: center;"><select id="RunType➩' + TableRowIndex + '" class="txtselect"><option value=""></option><option value="RunType_1"' + (i != 0 ? ' selected = "selected"' : '') + '>作者不存在執行</option><option value="RunType_All"' + (i == 0 ? ' selected = "selected"' : '') + '>都執行</option></select></td>'
        tr += '</tr>';
        $("#grid_Condition tbody").append(tr);
        TableRowIndex++;
    }
    $("#grid_Condition tbody tr").find('input,select').attr('disabled', 'disabled');
    $("#grid_Condition tbody tr:eq(0)").find('input,select').removeAttr('disabled');
    //$("#Logic➩1").attr('disabled', 'disabled');
    }

總結:
selected = “selected”
還是最好先實踐代碼。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章