How do the bloc text make the variable?



  • There's a few single blocks inside which there's a meaning of food and no, if the meaning is no, it's got to hide the element of the button, so the code below does work, but if we write this:

    var thereis = $(this).find(".onechild").text();
    

    work stops, although variable values thereis Still nothing

      $(".sibline").each(function(i) {
        var thereis = $(this).find(".onechild .val").text();
    
    if (thereis == 'Нет') {
      $(".sibline").find(".twochild").eq(i).css('display', 'none');
    }
    

    })

    .onechild {
    display: inline-block;
    position: relative;
    margin: 2px;
    padding: 3px;
    background: #ccc;
    }
    .twochild {
    display: inline-block;
    background: #CDDC39;
    padding: 3px;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    <div class="sibline">
    <div class="onechild">
    <div class="val">Есть</div>
    </div>
    <div class="twochild">
    <div class="val">Кнопка</div>
    </div>
    </div>
    <div class="sibline">
    <div class="onechild">
    <div class="val">Нет</div>
    </div>
    <div class="twochild">
    <div class="val">Кнопка</div>
    </div>
    </div>
    <div class="sibline">
    <div class="onechild">
    <div class="val">Есть</div>
    </div>
    <div class="twochild">
    <div class="val">Кнопка</div>
    </div>
    </div>
    <div class="sibline">
    <div class="onechild">
    <div class="val">Есть</div>
    </div>
    <div class="twochild">
    <div class="val">Кнопка</div>
    </div>
    </div>



  • Privacy

    var thereis = $(this).find(".onechild").text();
    

    thereis It's not 'Esty', but it's a word with four missing points (tabulation) and a line transfer.

    <div class="onechild">(перенос строки тут)
    (4 пробела тут)<div class="val">Есть</div>
    </div>
    

    введите сюда описание изображения




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2