I'm having hard time in to getting the data attribute set to select option on bootstrap selectpicker .
I tried:
$('.selectpicker').on('changed.bs.select', function (e) {
var selected = e.target.value;
console.log("value : ", selected ); // gives selected value
console.log("data attribute: ", $(e.target).data("price"));
});
data attribute always returns undefined
what wrong I'm doing here ?
This works.
$('.selectpicker').on("changed.bs.select", function() {
var dataTypeAttribute = $('option:selected', this).attr("data-type");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With