0

I have the following problem: I need that when the class "estadoEntregado" has the attribute "entrega" in "no", the comment button is deactivated.

I have tried to solve it in the way that I will share with Jquery, but it does not work.

I leave the html code of the section of the states and below the section of the button, which is in the same file, but I did not want to make the code so long, and only place what is relevant to the problem.

HTML

if($value1["envio"] == 0){

    echo '<div class="progress">

        <div class="progress-bar progress-bar-info" role="progressbar" style="width:33.33%">
            <i class="fa fa-check"></i> Aceptado
        </div>

        <div class="progress-bar progress-bar-default" role="progressbar" style="width:33.33%">
            <i class="fa fa-clock-o"></i> Enviando
        </div>

        <div class="progress-bar progress-bar-success" role="progressbar" style="width:33.33%">
            <i class="fa fa-clock-o estadoEntregado" entrega="no"></i> Entregado
        </div>

    </div>';

}

if($value1["envio"] == 1){

    echo '<div class="progress">

        <div class="progress-bar progress-bar-info" role="progressbar" style="width:33.33%">
            <i class="fa fa-check"></i> Aceptado
        </div>

        <div class="progress-bar progress-bar-default" role="progressbar" style="width:33.33%">
            <i class="fa fa-check"></i> Enviando
        </div>

        <div class="progress-bar progress-bar-success" role="progressbar" style="width:33.33%">
            <i class="fa fa-clock-o estadoEntregado" entrega="no"></i> Entregado
        </div>

    </div>';

}

if($value1["envio"] == 2){

    echo '<div class="progress">

        <div class="progress-bar progress-bar-info" role="progressbar" style="width:33.33%">
            <i class="fa fa-check"></i> Aceptado
        </div>

        <div class="progress-bar progress-bar-default" role="progressbar" style="width:33.33%">
            <i class="fa fa-check"></i> Enviando
        </div>

        <div class="progress-bar progress-bar-success" role="progressbar" style="width:33.33%">
            <i class="fa fa-check estadoEntregado" entrega="si"></i> Entregado
        </div>

    </div>';

}

Button section:

<a class="calificarProducto" href="#modalComentarios" data-toggle="modal" idComentario="'.$comentarios["id"].'">

    <button class="btn btn-default backColor" id="botonComentarios">Calificar Producto</button>

</a>

Jquery:

var attr = $('.estadoEntregado').attr('entrega');

// For some browsers, `attr` is undefined; for others,
// `attr` is false.  Check for both.
if (attr == "no") {

    $('#botonComentarios').attr("disabled", true);

}

1 Answers1

1

Which version of jQuery are you using? You can try to use .prop instead of .attrwhile setting disabled

So this is how it should look:

var attr = $('.estadoEntregado').attr('entrega');

if (attr === "no") {

    $('#botonComentarios').prop("disabled", true);

}

Read some more info here: http://api.jquery.com/prop/

TvZ
  • 26
  • 1
  • 4