Ticket #3514 (closed bug: invalid)
jquery.prev(expr) bug
| Reported by: | trisn | Owned by: | flesler |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3 |
| Component: | selector | Version: | 1.2.6 |
| Keywords: | Cc: | trisn, flesler | |
| Blocking: | Blocked by: |
Description
eg: <!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01 TransitionalEN"
<html> <head>
<script src=" http://code.jquery.com/jquery-latest.js"></script>
<script> $(document).ready(function(){
$("p").prev("div").prev("div").css("background", "yellow");
}); </script>
</head> <body>
<div><span>Hello</span></div> <script type="text/javascript">
(function($){ $(document).ready(function(){
});
})(jQuery); </script>
<p class="selected">Hello Again</p> <p>And Again</p>
</body> </html> As such a situation,they were spacing of the some javascript code.prev() isn't work.This is bug?
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

You're calling prev('div') twice and there's only one div.
Also, prev() returns just the first neighbor. If you want all the previous, you need to use prevAll().