How to show an alert to an ul tag that is disabled, jquery?

0

By having the tag disabled in the following way:

<ul class="lista_productos_elegir3" style="max-height: 55vh; overflow: scroll;" disabled="disabled"></ul>

Then I want to show an alert when they click on the disabled tag, indicating why the reason is disabled.

But neither access to the works.

$$('.lista_productos_elegir3').on('click',function(e){
  console.log("SELECCIONANDO UL");
});

There will be some way to control this.

    
asked by JG_GJ 27.09.2018 в 21:54
source

3 answers

2

The disabled property changes the cursor, which does not allow launching clicks events. I recommend you create a disabled class and give it the style.

$('input').click(function (event) {
        if ($(this).hasClass('disabled')) {
            alert('CLICKEADO, PERO DESHABILITADO!!');
        } else {
            alert('No deshabilitado. =)');
        }
    });
.disabled
{
    background-color: #DDD;
    color: #999;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" class="disabled" value="deshabilitado click" />

<input type="button" value="click habilitado!" />
    
answered by 27.09.2018 / 22:01
source
1

A list <ul> can not have an attribute disabled . You can use CSS to create an effect similar to disabled if you give pointer-events:none; and opacity:.5;

The disabled attribute can be used with the following elements: <button> <fieldset> <input> <optgroup> <option> <select> <textarea>

    
answered by 27.09.2018 в 22:12
0

Try this:

$('.lista_productos_elegir3').on('click',function(e){
  alert('Hola mundo');
});

Note: You can also customize an alert here

    
answered by 27.09.2018 в 22:04