Q:

jQuery - Compare two values and show or hide div

https://jsfiddle.net/6k6ehnn2/
Hello,
I need to make , if the value is greater than or equal to 1000.00 function display the div .boleto, but does not display ... Where am I going wrong in comparing the two strings?
<span class="valor">R$ 200,00</span>
<div class="boleto">pagamento em boleto</div>    

$(function(){
    var valorMinimoBoleto = '1000,00';
    var valorTratado = $(".valor").html().replace('R$ ','');
    var valorBoleto = valorTratado;
    if ( valorBoleto >= valorMinimoBoleto ) {           
        console.log('valor exibe boleto');
    } else {
        $('.boleto').hide();
        console.log('valor não exibe boleto');
    };    
});

A:

Its because both the valorMinimoBoleto and valorBoleto are Strings, so your if condition does not work there. 
So, first convert them into number using number() method like this

$(function(){
    var valorMinimoBoleto = 100000;
    var valorTratado = $(".valor").html().replace('R$ ','');
    var valorBoleto = Number(valorTratado);
     if ( valorBoleto >= valorMinimoBoleto ) { 
      console.log('valor exibe boleto');
     } else {
      $('.boleto').hide();
      console.log('valor não exibe boleto');
     };    
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="valor">R$ 200,00</span>
<div class="boleto">pagamento em boleto</div>

As LinkinTED 22 said, we can also use toggle() function instead of if..else, like this : 

$(function(){
    var valorMinimoBoleto = 100000;
    var valorTratado = $(".valor").html().replace('R$ ','');
    var valorBoleto = Number(valorTratado);
     $('.boleto').toggle( valorBoleto >= valorMinimoBoleto );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="valor">R$ 200,00</span>
<div class="boleto">pagamento em boleto</div>

Hope it helps :)

