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

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -