jqueryfunction addnewRows()
{
var idhidden=$("#idhidden").val();
var id=parseInt(idhidden);
var postid=id+1;
$("#idhidden").val(postid);

         $.post("addnewRows.php",{newId:postid},function(data){

  $("#a_div").append(data);//返回的是“<tr><td>fuck the world</td></tr>”
   })
}html
<table>
<tr><td>hello world</td><tr>//我想在下面两个tr之间显示jquery返回的值,所以就加了个div,可这样不行啊
<div id="a_div"></div>//加在俩个tr之间就不好用了
<tr><td><input type="hidden" id="idhidden" value='1'><input type='button' onclick="addnewRows"></td></tr>
</table>
前辈们如何在那两行直接接收返回的值啊.....请帮忙看看...小弟万分感谢

解决方案 »

  1.   

    这样可以?
    <table border="1">
    <tr id="a_tr"><td>hello world</td><tr>//我想在下面两个tr之间显示jquery返回的值,所以就加了个div,可这样不行啊<tr><td><input type="hidden" id="idhidden" value='1'><input type='button' onclick="addnewRows()"></td></tr>
    </table>
    <script type="text/javascript">
    <!--
    function  addnewRows() {
    $("#a_tr").after("<tr><td>fuck the world</td></tr>");
    }
    //-->
    </script>
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="http://code.jquery.com/jquery-1.6.2.min.js" type="text/javascript"></script>
        <script type="text/javascript">        function addnewRows() {
                $("table tr").eq(0).after('<tr><td>fuck the world</td></tr>');
                alert($("table").html());
            }
        </script></head>
    <body>
    <table>
    <tr><td>hello world</td></tr><tr><td><input type='button' value="Btn" onclick="addnewRows()"></td></tr>
    </table></body>
    </html>
      

  3.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="http://code.jquery.com/jquery-1.6.2.min.js" type="text/javascript"></script>
        <script type="text/javascript">        function addnewRows() {
                $("table tr").eq(0).after('<tr><td>fuck the world</td></tr>');    
            }
            function removenewRows() {
                $("table tr").eq(1).remove();
            }
        </script></head>
    <body>
    <table>
    <tr><td>hello world</td></tr><tr><td><input type='button' value="添加" onclick="addnewRows()"><input type='button' value="删除" onclick="removenewRows()"></td></tr>
    </table></body>
    </html>
      

  4.   


    前辈啊,我再问个简单的小问题哈我现在有一行
    产品名称                 金额
    <span>牙膏</span>      <span> 20</span>        总金额为20
    我又添加了一行
    <span>牙刷</span>      <span> 15</span>       总金额变成35
    可是现在我又想把刚刚添加的那行删除了,我就用的您的教给我的这个方法,可是删除后总金额还是35,应该变成20的啊,请问一下这在js或者jquery中要怎么运算啊...