Select element, ignoring specific class

2

Come on ... Suppose I have something similar to the list below.

<div id="respostas">
  <div class="historico">
    <div class="lista">
      <div class="enviando"><strong>verbot</strong> curar</div>
      <div class="enviando"><strong>verbot</strong> assustar</div>
      <div class=""><strong>verbot</strong> evoluir</div>
      <div><strong>Hideki_kf</strong> lagrima</div>
      <div><strong>Hideki_kf</strong> choro</div>
      <div class="sistema">A resposta era: <strong>chorar</strong></div>
      <div class="sistema">Intervalo...</div>
      <div class="vez">Sua vez, a palavra é: <strong>agrupar</strong></div>
      <div><strong>_Elfo</strong> af</div>
      <div class="sistema">Você pulou a vez!</div>
      <div class="sistema">Intervalo...</div>
      <div class="vez">Vez de <strong>lalua</strong></div>
      <div><strong>_Elfo</strong> ola victon</div>
    </div>
  </div>
</div>

I need a selector that captures the first DIV within the LIST, this is easy:

divUltimaMensagem = $("div#respostas div.historico div.lista div");

So far so good, I have a JS where I treat the contents of the DIV and in the end I remove the DOM's DIV.

My problem is: If the first DIV has the CLASS "sending", I can not remove it until the message has been sent, in which case the DIV that my selector has to pick up is first DIV that does not have the CLASS "sending", which in the example, is the 3rd

Is it possible to do this simply within that selector I am using? What should I change?

PS: It does not serve me answers involving more JS beyond what I showed here.

I want to know what I change in the selector below, to select the DIV that does not have the CLASS "sending", if it is possible to ignore a specific CLASS within the selector.

"div#respostas div.historico div.lista div"
    
asked by anonymous 04.07.2017 / 19:16

1 answer

4

You can capture it using the :not selector filtering the div's that does not have the class. enviando , along with the :first selector to get only the first div .

$(".lista div:not(.enviando):first").css("background-color", "yellow");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="respostas">
  <div class="historico">
    <div class="lista">
      <div class="enviando"><strong>verbot</strong> curar</div>
      <div class="enviando"><strong>verbot</strong> assustar</div>
      <div class=""><strong>verbot</strong> evoluir</div>
      <div><strong>Hideki_kf</strong> lagrima</div>
      <div><strong>Hideki_kf</strong> choro</div>
      <div class="sistema">A resposta era: <strong>chorar</strong></div>
      <div class="sistema">Intervalo...</div>
      <div class="vez">Sua vez, a palavra é: <strong>agrupar</strong></div>
      <div><strong>_Elfo</strong> af</div>
      <div class="sistema">Você pulou a vez!</div>
      <div class="sistema">Intervalo...</div>
      <div class="vez">Vez de <strong>lalua</strong></div>
      <div><strong>_Elfo</strong> ola victon</div>
    </div>
  </div>
</div>
    
04.07.2017 / 19:31