Bug Tracker

Modify

Ticket #3514 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

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"

" http://www.w3.org/TR/html4/loose.dtd">

<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

comment:1 Changed 5 years ago by flesler

  • Cc trisn, flesler added
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfilled to selector

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().

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.