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

2.5k views Asked by At

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

What option that work in ie6+ie7 exist in jQuery?

Delete edit because havy code

Thanks

1

There are 1 answers

7
T.J. Crowder On BEST ANSWER

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.