With optimized js enabled, my javascript code not working I have a drop down list. On the change event of the drop down list I have written some javascript code. When I select an option from the drop down list a site opens in the new window.

So for this I wrote some javascript code on the change event of the drop down list.

But the problem is that when I enable the optimize js files then my drop down change event does not work and when I disable the optimize js files then the change event of the drop down works.

So what should I do for this to work in both condition?

UPDATED:

Drupal.behaviors.change = function (context) {


    $(".test").change(function(){
        var page = $(".test").val();
        window.open(''+page+'', '_blank');
    }) ;

};
The reason maybe is your custom script loads first before the Jquery script.

Try this:

(function($) {
  $(function() { 
    //your script here
  });
})(jQuery);


or

Drupal.behaviors.somethingHere = function (context) {
  //your script here
}