开发者

This jQuery code only works in IE - how to make it compatible with all browsers?

How do I make this code work in all browsers?

<script>
var $j = jQuery.noConflict();

$j(document).ready(function(){
    if ($j.browser.msie) {
        $j('.rou开发者_StackOverflow中文版nd').append('<div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div>');
    }
});
</script>


Unless I'm missing something, just take out your if:

var $j = jQuery.noConflict();

$j(document).ready(function(){
  $j('.round').append('<div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div>');
});

Now that if was probably there for a reason, maybe some IE specific CSS hackery going on? In that case it's a CSS issue, not a JavaScript one outside of this. Something like the jQuery corners plugin may be what you're ultimately after. Other/newer browsers support rounded corners natively, this is mainly an IE fix.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜