0

我想一次在警报消息中显示表格的第一行

function GetCellValues() {
    var rows = document.getElementsByTagName('tr');
    for (var c = 0; c < rows.length; c++) {
        var row = rows[c];
        var inputs = row.getElementsByTagName('input');
        for (var k = 0; k < inputs.length; k++) {
            alert(inputs[k].value);

            //here I want some code to show the first table row at a time.        
        }
    }
}

window.onload = function () {
    makeTable();
};
4

1 回答 1

0

尝试这个,

function GetCellValues() {
    var rows = document.getElementsByTagName('tr');
    for (var c = 0; c < rows.length; c++) {
        var row = rows[c];
        var inputs = row.getElementsByTagName('input');
        var inputValList=[];
        for (var k = 0; k < inputs.length; k++) {
           // alert(inputs[k].value);
             inputValList.push(inputs[k].value);

        }
        if(inputValList.length>0){
           alert(inputValList);
        }
    }
}

我只是希望...这将解决您的问题。

于 2013-11-06T12:31:05.390 回答