Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
How to get an HTML element by his content?

I need to modify the HTML of an element at the loading of the page so it's not on a event.

The things I can do is to get all informations that this element contains (like name, state etc...) with this:

Meteor.call("whereAreYou",function(err,succ){
    if(err){
      console.error(err);
    }else{
      console.log(succ);
      if(succ == undefined){
        Session.set("isNotHome", false)
      }else{
        var theMachine = InfosMachines.find { ipAddr: succ };
        //change the HTML
        Session.set("isNotHome",true);
      }
    }
  });

and the structure of the element is:

<li class="liMachine switch">
        <div id="nameMachine">
            <h3>{{nameMachine}}</h3>
        </div>
        <div id="stateMachine">
            State:<span class="state">{{stateMachine}}</span>
        </div>
        {{#if is_running_machine}}<i class="fa fa-spinner fa-spin"></i>{{else}}<button type="button" class="stop {{#if to_hide_stopM}}hidden{{/if}}"></button>{{/if}}
        {{#if is_alive_machine}}<i class="fa fa-spinner fa-spin"></i>{{else}}<button type="button" class="kill {{#if to_hide_stopM}}hidden{{/if}}"></button>{{/if}}
        {{#if is_stopped_machine}}<i class="fa fa-spinner fa-spin"></i>{{else}}<button type="button" class="start {{#if to_hide_startM}}hidden{{/if}}"></button>{{/if}}
    </li>

I want to do something like

element where nameMachine is "XX" do ....

But I don't know how to make the request.

Someone could put me on the right track ?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If you're happy with a case insensitive match on any part of the string you can use :contains:

$('#nameMachine h3:contains("XX")');

Alternatively, if you require a full match of the string with case sensitivity you can use filter():

$('#nameMachine h3').filter(function() {
  return $(this).text().trim() == 'XX';
}) 
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda