Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery: I'm trying to disable all buttons except the clicked button and not working

Tags:

html

jquery

I want to disable all buttons except the clicked, I'm using jquery. Help please. SOLVED: removing :input inside '.not()'.

HTML

<div id="buttongroup">
    <ul>
        <li>
            <input type="button" id="butDes" class="butFiltro" value="Descripción" />
        </li>
        <li>
            <input type="button" id="butMaq" class="butFiltro" value="Máquina" />
        </li>
        <li>
            <input type="button" id="butDen" class="butFiltro" value="Denominación" />
        </li>
        <li>
            <input type="button" id="butFecEd" class="butFiltro" value="Fecha edición" />
        </li>
        <li>
            <input type="button" id="butFecCie" class="butFiltro" value="Fecha cierre" />
        </li>
        <li>
            <input type="button" id="butOpe" class="butFiltro" value="Operario" />
        </li>
        <li>
            <input type="button" id="butNue" class="butFiltro" value="Nuevo" />
        </li>
    </ul>
</div>
</div>

JAVASCRIPT

$('input[type=button]').click(function(){
//$('.butFiltro').click(function(){

    var getValueButton = this.id;
    alert(getValueButton);
    $(':input').not('#'+getValueButton).attr('disabled', true);

});
like image 817
jal Avatar asked Dec 21 '22 05:12

jal


1 Answers

Change var getValueButton = $(this).id; to var getValueButton = this.id

Also use .prop instead of attr,

var $inputBtns = $('input[type=button]');

$inputBtns.click(function(){
    var getValueButton = this.id;
    $inputBtns.not('#'+getValueButton).prop('disabled', true);
});
like image 165
Selvakumar Arumugam Avatar answered Dec 24 '22 11:12

Selvakumar Arumugam