简体   繁体   English

jQuery animate()和slideUp()在IE8中不起作用

[英]jquery animate() and slideUp() don't work in IE8

I'm animating table rows to slide up when deleting them, with jquery , which is cool in FF, Safari and Chrome. 我正在使用jquery table行的动画,以便在删除它们时向上滑动,这在FF,Safari和Chrome中很酷。 But surprise, suprise...!! 但是惊喜,惊喜...! It doesn't work in IE8. 在IE8中不起作用。 The worst thing is that IE8 doesn't show any error, so how am I supposed to debug. 最糟糕的是IE8没有显示任何错误,所以我应该如何调试。

Also I know table s are problematic when it comes to effects. 我也知道table s在效果方面存在问题。 That's why I replaced tr with a div using replaceWith() . 这就是为什么我使用replaceWith()tr替换为div的原因。

Here's my jquery: 这是我的jQuery:

$('.remove').live('click', removeRowSlider);

function removeRowSlider(e){
  var thisElem = $(this);

  if( thisElem.hasClass('remove') ){
    var tr = thisElem.closest('tr').parents('tr'),
            supportDiv = $('<div style="height: 30px; width: 470px">').css({'height': tr.height()});

    tr.animate({'opacity': 0.2}, function(){
        tr.replaceWith(supportDiv);

        supportDiv.slideUp(400, function(){
            $(this).remove();               
        });

    });

  }

  e.preventDefault();
}

HTML: HTML:

<table>
    <thead>
    <tr>
        <th class="first-td">Item(s)</th>
      <th class="qty-col">Qty</th>
      <th class="price-col">Price</th>
      <th class="price-col">Subtotal</th>
      <th class="del-opt">Delivery options</th>
    </tr>
  </thead>
  <tbody>
    <tr>
        <td colspan="4">
        <table>
            <tr>
            <td class="first-td">
                <img src="../assets/product-image.jpg" alt="product image" />
              <div class="prod-desc-col">
                <h3>Samsung LE40C580J1 LCD HD 1080p </h3>
              </div>
            </td>
            <td class="qty-col">
                <input type="text" value="1" />
              <a href="#" title="Update" class="update">Update</a> 
              <a href="#" title="Remove" class="remove">Remove</a>
            </td>
            <td class="price-col">&pound;12223.00</td>
            <td class="price-col">&pound;12223.00</td>
          </tr>
        </table>
      </td>
      <td>
        <ul class="font-small">
          <li class="coll-store">
            <p>Collect from store</p>
          </li>
          <li class="uk-del">
            <p>Delivery to UK</p>
          </li>
        </ul>
      </td>
    </tr>
    <tr>
        <td colspan="4">
        <table>
            <tr>
            <td class="first-td">
                <img src="../assets/product-image.jpg" alt="product image" />
              <div class="prod-desc-col">
                <h3>Samsung LE40C580J1 LCD HD 1080p </h3>
              </div>
            </td>
            <td class="qty-col">
                <input type="text" value="1" />
              <a href="#" title="Update" class="update">Update</a> 
              <a href="#" title="Remove" class="remove">Remove</a>
            </td>
            <td class="price-col">&pound;12223.00</td>
            <td class="price-col">&pound;12223.00</td>
          </tr>
        </table>
      </td>
      <td>
        <ul class="font-small">
          <li class="coll-store">
            <p>Collect from store</p>
          </li>
          <li class="uk-del">
            <p>Delivery to UK</p>
          </li>
        </ul>
      </td>
    </tr>
    <tr>
        <td colspan="4">
        <table>
            <tr>
            <td class="first-td">
                <img src="../assets/product-image.jpg" alt="product image" />
              <div class="prod-desc-col">
                <h3>Samsung LE40C580J1 LCD HD 1080p </h3>
              </div>
            </td>
            <td class="qty-col">
                <input type="text" value="1" />
              <a href="#" title="Update" class="update">Update</a> 
              <a href="#" title="Remove" class="remove">Remove</a>
            </td>
            <td class="price-col">&pound;12223.00</td>
            <td class="price-col">&pound;12223.00</td>
          </tr>
        </table>
      </td>
      <td>
        <ul class="font-small">
          <li class="coll-store">
            <p>Collect from store</p>
          </li>
          <li class="uk-del">
            <p>Delivery to UK</p>
          </li>
        </ul>
      </td>
    </tr>
  </tbody>
</table>

Thanks for your help... 谢谢你的帮助...

When it comes to IE, nothing surprises me! 谈到IE,没有什么让我感到惊讶! I don't know if this works with your example, but sometimes I've had problems appending elements without an end-tag. 我不知道这是否适用于您的示例,但是有时我在附加没有结束标签的元素时遇到了问题。 So you could try this: 因此,您可以尝试以下操作:

supportDiv = $('<div style="height: 30px; width: 470px;"></div>')...

Hope it works out for you! 希望可以帮助你!

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

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