Topic: How to trigger on change event under materialSelect() function
                  
                  Alfonso Marrero
                  pro
                  asked 7 years ago
                
<select class="mdb-select md-form colorful-select dropdown-primary"> <option data-ports="24" value="switch-24">Switch 24P</option> <option data-ports="32" value="switch-32">Switch 24P</option> <option data-ports="40" value="switch-40">Switch 24P</option> <selectTrying to trigger the on change event to gather the data value and update few fields. I am using Jquery as follow:
$('.mdb-select').on("change", function(){ 
alert($(this).data('ports'));
});
So, I am not been able to triger the on change event, any suggestions?
Thanks
                
                  
                      
                      Jakub Strebeyko
                      staff
                        answered 7 years ago
                    
Alfonso Marrero pro commented 7 years ago
Thanks, here is the right way:
$('.mdb-select').materialSelect();
$('.mdb-select').on("change", function(event) {
    alert($(event.target).find(':selected').data("ports"));
});
Rgds,
A. Marrero
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
 - Premium support: No
 - Technology: MDB jQuery
 - MDB Version: 4.5.10
 - Device: PC
 - Browser: IE
 - OS: Windows
 - Provided sample code: No
 - Provided link: No