开发者

jQuery: what does this code do?

l = $("#chat > div.monologue:last开发者_开发知识库 div.message:not(.pending):last");


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


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>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜