How to use event trigger when change "State/Province " drop-down on the checkout page?

I'm trying to page reload when user change Region from "State/Province" dropdown in the checkout page.

First, I've created js file and put code and this js add in frontend using article but it's not worked

also, I have put static JS file in XML file but there give a JQuery not defined error. see below js file code

function($) {
   "use strict";
    $('document').on('change', 'select[name="region_id"]', function(){

put an alert('test'); in your js file or check in debugger tool whether your js is getting called or not, if it gets called then use this in you file:

jQuery('document').on('change', '**identifier-of-the-field**', function(){
   //opertation to be performed
  • alert('test'); is working fine but when i put "jQuery('document').on('change..." code give a error " jQuery is not defined"
    – nil108
    Feb 15 '17 at 12:46
  • can you show your js file?
    – Manish Joy
    Feb 15 '17 at 12:48
  • or you can use $ in place of jQuery
    – Manish Joy
    Feb 15 '17 at 12:51
  • you used jquery in magento 2 standard format. So it will not give error like not defined. Feb 15 '17 at 12:57
  • i update my question
    – nil108
    Feb 15 '17 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.