0
<html><head>
    <script src="js.js"></script>
    <title></title>
</head>
<body>

<table border=1>
<tr><div id="addonlocation"></div></tr>
<tr><div id="addonmatter_1"><td>am1.1</td><td>am1.2</td><td>am1.3</td></div></tr>
<tr><div id="addonmatter_2"><td>am2.1</td><td>am2.2</td><td>am2.3</td></div></tr>
<tr><div id="addonmatter_3"><td>am3.1</td><td>am3.2</td><td>am3.3</td></div></tr>

<script>
$(document).ready(function(){
    var ww=$(window).width();
    var addonmatter1=$("#addonmatter_1").html();
    var addonmatter2=$("#addonmatter_2").html();
    var addonmatter3=$("#addonmatter_3").html();
    var shifter= addonmatter1 + addonmatter2 + addonmatter3;
    if (ww<460) {$("#addonlocation").html(shifter)};
});
</script>
</body>
</html>

现在这就是我想要的:第二个、第三个和第四个内部的所有数据(或文本)应该在第一个之后组装以创建一个单行。

4

1 回答 1

0

you can do this by looping through your tr's and removing them after you've added their content to a temporary variable. After adding all the tr's content to the variable, wrap them in a tr, and append the variable to the table. http://jsfiddle.net/nRJqA/1/

var content = "";
$('tr').each(function(){
    content += $(this).html();
    $(this).remove();
});
content = '<tr>'+content+'</tr>';
$('table').append(content);
于 2013-11-13T14:50:27.670 回答