开发者

Jquery .next() - not compatible for ie 6+7? What should I use?

jQuery .next() - not compatible for ie 6+7 (write warning in netbeans editor).

What option that work in ie6+ie7 e开发者_开发百科xist in jQuery?

Delete edit because havy code

Thanks


next works just fine in IE6 and IE7.

Example:

HTML:

<div id='container'>
  <div>Target A</div>
  <div>Target B</div>
  <div>Target C</div>
</div>

JavaScript:

jQuery(function($) {

  $("#container div").click(function() {
    var next = $(this).next();
    if (next.length == 0) {
      display("There's no div after this one");
    }
    else {
      display("The next div's text is: " + next.text());
    }
  });

  function display(msg) {
    $("<p/>").html(msg).appendTo(document.body);
  }

});​

Live copy

Tested and working in IE6 and IE7, both of which are on jQuery's list of supported browsers.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜