The jquery event does not capture me

0

I have the following code to select an address with a bootstrap glyphicon, but, I do not capture the event.

            <td>
               <a href="#" class="selectpoblacion" data-  poblacion="@dir.DireccionEnvio">
               <span class='glyphicon glyphicon-arrow-right'> </span></a>
           </td>

           $('a .selectpoblacion', this).on('click', function (e) {
                e.PreventDefault()
                var prueba = (this).data("poblacion");
                console.log(prueba)
                $("#cambiar .close").click()//CERRAR MODAL
            });
    
asked by Alcides Salazar 21.12.2016 в 18:09
source

2 answers

2

Test:

$('a.selectpoblacion').on('click', function(e){
  e.preventDefault();
})

You have a space inside the declaration of the selector.

    
answered by 21.12.2016 в 18:13
0

You have one more space in the attribute:

<a href="#" class="selectpoblacion" data-  poblacion="@dir.DireccionEnvio">
                                       ☝☝☝

It should be data-poblacion .

    
answered by 21.12.2016 в 21:29