CSS3PIE is a very useful and powerful way to simulate CSS3 rounded corners - and at my company we chose this, but there are many other ways to do this.
As CSS3PIE creates rounded corners, it will create the <css3-container> as the previous sibling that has a behavior attribute, so it will change the DOM structure and break your prev() calls. The css container is important because it is a VML drawing of a rounded background behind the <pre> .
One way to do this is to wrap the <pre> in something like <div> , and then use <div> to navigate the DOM using the prev() function.
Another way you could do this is to create a jQuery plugin like this
/* This adds a plugin prevPie and nextPie - it is the same as the existing prev and next, but it will ignore css3-containers. */ (function($){ function addPlugin(name) { $.fn[name + 'Pie'] = function() { var result = []; this[name]().each(function(i,el){ if (el.tagName == 'css3-container') { var val = $(el)[name]()[0]; val && result.push(val); } else { result.push(el); } }); return $(result); } } addPlugin('prev'); addPlugin('next'); })(jQuery);
Now the following should work the way you want it to be in all browsers.
// undefined expected: getme alert($("pre").prevPie().attr("class")); // css3-container expected: p alert($("pre").prevPie()[0].tagName); // getme expected: foo alert($("pre").prevPie().prevPie().attr("class")); // P expected: div alert($("pre").prevPie().prevPie()[0].tagName));
source share