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 ?
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';
})