JQuery Function is not defined in scripts file -


apparently jquery function not defined. have no idea why. calling jquery before scripts file thats not case , jquery working fine before put in function.

(function ($) {  function selectcharacter(){     $('select.character_select').change(function(){          alert('select field value has changed to' + $('select.character_select').val());        }); }  })(jquery);   selectcharacter(); 

this scope issue. function creates new scope. so, you're trying invoke private variable function outside of function. can fix changing invoke function:

(function ($) {     function selectcharacter() {         $('select.character_select').change(function() {             alert('select field value has changed to' + $('select.character_select').val());         });     }            selectcharacter(); })(jquery); 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -