English 中文(简体)
我如何把 j印从我的桌子上破碎下来。
原标题:How do I keep javascript from breaking my table in a for loop?

问题一在于,当我试图通过javascript制作一张桌子时,我实际上把桌子放在最后的桌子上。

I m using this solution to record/read cookies https://stackoverflow.com/a/1960049

我所需要的是,通过所有 co,把 wish子放在桌面上,从这种“传闻”中挑选出一个希望的名字。 (四)

function loopArray() { 
      var cookie = $.cookie("testCookie"); 
      var items = cookie ? cookie.split(/,/) : new Array();


     $( #catalog ).empty();
     $( #catalog ).append("<table><tr><th>Part #</th><th>Delete</th></tr>");

     for(var i=0;i<items.length;i++){
         $( #catalog ).append("<tr><td width= 150 >"+items[i]+"</td><td><a href= javascript:;  onclick= remNum("+i+") ><img src= searchAssets/img/delete.png  /></a></td></tr>");
     }

     $( #catalog ).append("</table>");

}

不能肯定为什么这赢得了工作。 挤满了内部的超文本,但给我带来了问题,我尝试使用文件。 书写字,但在利用remNum功能去除 co具和复读清单时,我全页空。

这正是我所认为的。

<table><tbody><tr><th>Part #</th><th>Delete</th></tr></tbody></table><tr><td width="150">three</td><td><a href="javascript:;" onclick="remNum(0)"><img src="searchAssets/img/delete.png"></a></td></tr>
最佳回答

页: 1 你必须增加完全形成的超文本。 这一行文如下:$(#catalog ).append ("<table><<th>/th><th>Delete</th></tr>”); 是一个真正的问题,因为它只是一个有效的超文本,其本身无效。

你们可以做的是,在座右翼中积累了部分的超文本,最后将一分钟的结晶推向OM。

或者,你可以增加表格中完全形成的超文本,但无增长,然后在座右边插入一整段。

您不能做的是:<代码>和t;table>,然后是一些行文,然后是<代码></table>。 附录制造了世界卫生组织的超文本物体,其编号为<table> 质疑浏览器将其全部物体除去或否决整件。

例如,你可以这样做:

function loopArray() { 
  var cookie = $.cookie("testCookie"); 
  var items = cookie ? cookie.split(/,/) : new Array();
  var html = "<table><tr><th>Part #</th><th>Delete</th></tr>";

  for(var i=0;i<items.length;i++){
     html += "<tr><td width= 150 >"+items[i]+"</td><td><a href= javascript:;  onclick= remNum("+i+") ><img src= searchAssets/img/delete.png  /></a></td></tr>";
  }
  html += "</table>";
  $( #catalog ).html(html);

}
问题回答

你的所作所为是错误的。

在您的案例中,我建议你把他们放在最后的位置上。 见下文。

 $( #catalog ).empty();
 var tableContent = [];

 tableContent.push("<table><tr><th>Part #</th><th>Delete</th></tr>");

 for(var i=0;i<items.length;i++){
     tableContent.push("<tr><td width= 150 >"+items[i]+"</td><td><a href= javascript:;  onclick= remNum("+i+") ><img src= searchAssets/img/delete.png  /></a></td></tr>");
 }

 tableContent.push("</table>");

 $( #catalog ).html(tableContent.join(  )); //using .html as you had it emptied earlier.




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签