Javascript 如何将数组中的表安排为原型?

Javascript 如何将数组中的表安排为原型?,javascript,arrays,prototype,Javascript,Arrays,Prototype,所以,我想修改数组,使其在表中一行一行地一次性显示其内容。使用下面的代码,它会逐步显示代码,每个元素出现不止一次 如何解决这个问题?thx $(function() { Array.prototype.ToTable=function(){ tabelul="<center><table border><tr>"; for(a=0; a<this.length;a++){ this[a]=tabelul+="<td> <div

所以,我想修改数组,使其在表中一行一行地一次性显示其内容。使用下面的代码,它会逐步显示代码,每个元素出现不止一次

如何解决这个问题?thx

$(function() {

Array.prototype.ToTable=function(){

tabelul="<center><table border><tr>";

for(a=0; a<this.length;a++){

this[a]=tabelul+="<td> <div class='Expresion'>" + this[a] + "</div></td></tr>"
}


}

vaz=['one', 'two', 'three','four'];


vaz.ToTable();

$('#show').html(vaz)
})

<div id="show"></div>
$(函数(){
Array.prototype.ToTable=function(){
tabelul=“”;

对于(a=0;a我相信你的意思是这样的:

for(a=0; a<this.length;a++){
 tabelul+="<tr><td><div class='Expresion'>" + this[a] + "</div></td></tr>";
}
js:

$(函数(){
Array.prototype.ToTable=function(){
var tabelul=“”;

对于(var a=0;a我相信你的意思是这样的:

for(a=0; a<this.length;a++){
 tabelul+="<tr><td><div class='Expresion'>" + this[a] + "</div></td></tr>";
}
js:

$(函数(){
Array.prototype.ToTable=function(){
var tabelul=“”;

for(var a=0;athx for your replay。我需要数组的元素按行[一个接一个]而不是按列显示。@ChrisGP-哦,稍微调整一下,然后看标记为行的演示。现在它可以工作了。您还用
这个[a]更正了
a
.thx.另一个问题。如何将另一个数组中的链接和照片附加到数组的每个元素
var Links=new array();Links[0]='';Links[1]='';Links[2]='';Links[3]='';Links[4]='';
它只适用于一个例外。照片的位置[Links]应该在第一个数组的元素前面。现在它们在后面。thx供您重播。我需要数组的元素按行[一个在另一个下面]显示,而不是按列显示。@ChrisGP-哦,稍微调整一下,然后,请参见标记为行的演示。现在它可以工作了。您还用
这个[a]更正了
a
.thx.另一个问题。如何将另一个数组中的链接和照片附加到数组的每个元素
var Links=new array();Links[0]='';Links[1]='';Links[2]='';Links[3]='';Links[4]='';
它只适用于一个例外。照片的位置[Links]应该在第一个数组的元素前面。现在它们在后面。
$(function() {
 Array.prototype.ToTable=function(){
  var tabelul = "<center><table border>";
  for(var a=0; a<this.length;a++){
   tabelul += "<tr><td><div class='Expresion'>" + this[a] + "</div></td></tr>"
  }
  tabelul += "</table></center>";
  return tabelul;
 };
 vaz=['one', 'two', 'three','four'];
 $('#show').html(vaz.ToTable())
})
var Links= new Array(); 
Links[0]='<a href="http://location.com/"><img src="http://photo1.com/"></a>'; 
Links[1]='<a href="http://location.com/"><img src="http://photo2.com/"></a>'; 
Links[2]='<a href="http://location.com/"><img src="http://photo3.com/"></a>'; 
Links[3]='<a href="http://location.com/"><img src="http://photo4.com/"></a>'; 
Links[4]='<a href="http://location.com/"><img src="http://photo5.com/"></a>';

var vaz=['one', 'two', 'three','four'];

for( var i = 0; i < vaz.length; i++ )
{
 vaz[i] = Links[i] + vaz[i];
}