How to get the value of an html attribute, using jquery?

0

I have the following input

<input type="checkbox" name="cupon_check" class="cupon_check" attr-num-doc="D00001" attr-sub-tipo="2" value="12848">

and I'm trying to get the vator of 'attr-sub-type in the following way:

$(".cupones_bienvenida_costarica").find(".cupon_check[attr-num-doc='" + nombre_cupon + "']:checked").each(function(index,value){
                    console.log("CUPONES BIENVENIDA");
                    console.log($(this).data("sub-tipo"));
                });

I do it in that way since I must get that value from several input checkboxes that are selected. but it does not work for me.

Thank you very much in advance

    
asked by JG_GJ 29.11.2018 в 01:56
source

1 answer

3

The problem is that you are using the function .data of jQuery, this works to extract HTML attributes that begin with "data- " , the attribute that you use is not like that, change it by .attr('attr-sub-tipo') , this function works for any attribute .

    
answered by 29.11.2018 в 02:40