The problem I am encountering is that when I add the alert command the code works, but if I remove it, it does not work. Very strange. 
How can I make it work without alert command? 
The code below works with alert, but not without. 
  $(function(){ 
                    $('.page-links').click(function() {
                      $('#page').load('page' + $(this).data('target') + '.html');
                    }); 
    $('[data-target]').on('click', function() {
         var NavigationNumber = $(this).attr('data-target'); 
            // If and if only page18 is clicked, run diagram18.js
            if (NavigationNumber == 18) {
                alert(NavigationNumber);
                // Run diagram18.js
                    $.getScript("SensorTables/diagram" + NavigationNumber + ".js", function() {
                        window['diagram' + NavigationNumber]();
                    });
    });
 });
 
     
    