简体   繁体   English

FF中的jQuery .appendTo()用法可中断格式设置

[英]jQuery .appendTo() usage in FF breaks formatting

I'm making a simple shopping cart for my site. 我正在为我的网站制作一个简单的购物车。 On an item's description page, after clicking the 'add to cart' button, the item appears at the bottom of your list of items in your shopping cart. 在商品的说明页面上,单击“添加到购物车”按钮后,该商品出现在购物车中商品列表的底部。 It works perfectly in Chrome and IE9 but Firefox (v6 in this case) breaks the nice formatting. 它可以在Chrome和IE9中完美运行,但是Firefox(在本例中为v6)破坏了很好的格式。 The appendTo is able to make all the information appear, but in Firefox all the items in the cart (which are in an HTML table) lose there formatting. appendTo能够显示所有信息,但是在Firefox中,购物车中的所有项目(位于HTML表格中)都失去了此处的格式。 The text and pictures in the table move around (for all the items. not just the new one). 表格中的文字和图片会四处移动(对于所有项目。不只是新项目)。

 $.post(
        'handlers/addToCart.php',
        {cartItem:"<?php echo $itemID; ?>"},
        function(data){             
            if(data.num > 0){$('#empty').hide();}
            //append new to item to bottom to cart
            $(data.insert).hide().appendTo('#contents').show(1200);
        },
        "json"
        );

this is the html that gets echoed to be appended to the table: 这是被回显以附加到表的html:

       <tr>
            <td>
            </td>
            <td>
                <a href=\"http://www.mysite.com/spotlight.php?itemNo=$cID\">
                    <img src=\"$cthumb\" width=\"40\" height=\"35\" />
                </a>
            </td>
            <td>
                <a href=\"http://www.mysite.com/spotlight.php?itemNo=$cID\">$cname</a>
            </td>
        </tr>
        <tr>
                <td>
                    <img src=\"img/delete_x.gif\" width=\"20\" height=\"20\" id=\"$cID\" alt=\"$cfname\" class=\"delx\" onclick=\"delCartItem(id,alt)\" />
                </td>
                <td colspan=\"2\" class=\"cartPrice\">
                    \$$cprice
                </td>
        </tr>
        <tr><td colspan=\"3\"><hr /></td></tr>

and this is the cart with 1 item already in it: 这是已经有1件商品的购物车:

<table id="contents">
    <tr><td colspan="3"><hr /></td></tr>
    <tr>
        <td>
        </td>
        <td>
            <a href="http://www.mysite.com/spotlight.php?itemNo=981">
                <img src="thumb/pro.png" width="40" height="35" />
            </a>
        </td>
        <td>
            <a href="http://www.mysite.com/spotlight.php?itemNo=981">Product ABC</a>
        </td>
    </tr>
    <tr>
            <td>
                <img src="img/delete_x.gif" width="20" height="20" id="981" alt="ABC" class="delx" onclick="delCartItem(id,alt)" />
            </td>
            <td colspan="2" class="cartPrice">
                $40.00
            </td>

    </tr>
    <tr><td colspan="3"><hr /></td></tr>
</table>

尝试$('#contents')。append(data.insert)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM