有人能幫助我如何讓我的id變量在全球範圍內?這裏有什麼問題?如何讓我的ID變量在全球範圍內?
var id;
function GenerateTableFromJson(objArray) {
var tableContent =
'<table id="FilesTable" class="table table-striped table-bordered" cellspacing="0" width="100%">' +
'<thead><tr>' + '<th>ID</th>' + '<th>Actions</th>' + '</tr></thead>';
for (var i = 0; i < objArray.length; i++) {
tableContent += '<tr>';
tableContent += '<td>' + objArray[i].Id + '</td>';
tableContent += "<td><a id='" + objArray[i].Id + "' href='#' style='color: orange' class='confirmEditFileLink'>" +
"<i class='glyphicon glyphicon-pencil' title='Edit Item'></i></a>  ";
tableContent += "<a id='" + objArray[i].Id + "' href='#' style='color: red' class='confirmDeleteFileLink'>" +
"<i class='glyphicon glyphicon-remove' title='Delete File'></i></a>  ";
tableContent += "<a id='" + objArray[i].Id + "' href='#' class='confirmListItemDetailsLink'>" +
"<i class='glyphicon glyphicon-cog' title='Link to List Item'></i></a></td>";
tableContent += '</tr>';
var intmaxId = objArray[i].Id;
id = intmaxId;
//windows.id = intmaxId;
return id;
}
return tableContent;
};
console.log(id);
你怎麼能說你的'id'不是全球? – Roljhon
chek Arun Sivan回答:) –