0
I’d like to do two things:
- One that the labelidcnt, when pressed the button more, add 1 more and when pressed the button less, subtract 1 less.
- Other than that, when the labelcntequals zero, withdraws classpizzaselecionada.
Make the class change if the label=#cnt is equal to 0
<script>
   $(document).ready(function(e) {
        var Total = parseFloat('0');
        var P = $('.pizzadisponivel label').attr('value');
        var Pp = (P.replace(/,/,'.'));
        var cn = parseFloat('0');
    $('#mais').click(function(e) {
        $('li').hasClass('pizzadisponivel');
        $('li').removeClass('pizzadisponivel');
        $('li').addClass('pizzaselecionada');
        Total += parseFloat(Pp);
        $("#teste").html('R$' + parseFloat(Total).toFixed(2));
        alert(Total)
});
    $('#menos').click(function(e) {
        if ($('label #cnt').){ 
            $('li').hasClass('pizzaselecionada');
            $('li').removeClass('pizzaselecionada');
            $('li').addClass('pizzadisponivel');
        }
      else  {Total -= parseFloat(Pp);
            $("#teste").html('R$' + parseFloat(Total).toFixed(2));
            alert(Total);
        }
});
});
</script>
</head>
<body>
    <div>
        <li class="pizzadisponivel"><label value="29,90">29,90</label></li>
        <button id="mais">mais</button>
        <button id="menos">menos</button>
        <label id="cnt">0</label>
        <label id="teste">R$0,00</label>
    </div>
</body>
</html>
Friend, we know you want something(s) (s). Try to indicate in the title what you want. Don’t take this as a negative review... but that’s how it works Sopt.
– Andrey
All right, thank you very much, I’ll put it right in the title
– Pablo Costa