views:

80

answers:

2
l = $("#chat > div.monologue:last div.message:not(.pending):last");
+8  A: 

It's getting last the <div class="message"> that doesn't have a the class pending" that's a decendant of the last <div class="monologue"> that's a direct child of the id=chat" element.

Since it looks like you're looking at SO chat code, here's the plain version:
It's getting the last chat message that's not one you just sent (and hasn't been confirmed by the server).

Nick Craver
hoho, looks like you are the developer of SO?
Bin Chen
@Bin - nope :) I just helped debugging a bit in the beta so your code's familiar :)
Nick Craver
+1  A: 

It targets the last <div class="message"> of <div class="monologue"> and makes sure it doesn't have pending in the class attribute. Now the parent div, which is <div class="monologue">, should be the last from its parent div, which is <div id="chat">.

To make it clear see below:

<div id="chat">
  <div class="monologue"></div>
  <div class="monologue"></div>
  <div class="monologue">
      <div class="message pending"></div>
      <div class="message pending"></div>
      <div class="message"></div>
      <div class="message"></div>

      <!-- it's targeting this div -->
      <div class="message"></div>
  </div>

Shaoz