Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get data attribute from radio button with jQuery

I have the following html convertd to haml:

%input#insurance_isp_payment{ checked: "checked", type: "radio", name: "insurance_isp_payment", price: 27.22, value: "single"}
27,22 €

And now I want to get this price value from radio button which is checked. I tried something like that:

$('input[name=insurance_isp_payment]:checked').data("price")

But this not work. How can I solve this problem?

like image 375
Mateusz Urbański Avatar asked Sep 10 '14 09:09

Mateusz Urbański


1 Answers

Try this : instead of data() use attr() to get the price value.

var price = $('input[name="insurance_isp_payment"]:checked').attr("price");
alert(price);
like image 197
Bhushan Kawadkar Avatar answered Oct 15 '22 21:10

Bhushan Kawadkar