Skip to content

Instantly share code, notes, and snippets.

@mehedicsit
Last active October 1, 2019 04:31
Show Gist options
  • Save mehedicsit/39ca0a6ae49f0ebd84bdb4d8c523d585 to your computer and use it in GitHub Desktop.
Save mehedicsit/39ca0a6ae49f0ebd84bdb4d8c523d585 to your computer and use it in GitHub Desktop.
Get data attribute from radio button for on change event with jQuery
jQuery(document).on('change', 'tag or class name', function() {
// Does some stuff and logs the event to the console
var packPrice=jQuery(this).attr("data-price");
jQuery('span.totalprice').text("$"+packPrice);
});
//onchnage with calculation
jQuery(document).on('change', 'input.pbu-package, input.field-element.numberlicenses', function() {
var packPrice=jQuery('input.pbu-package:checked ').attr("data-price");
var licenseincrement=jQuery('input.field-element.numberlicenses').val();
jQuery('span.totalprice').text("$"+packPrice * licenseincrement);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment