Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!