2017-10-20 48 views
0

我的小页面,用户必须选择4的东西,一旦选择了最后一个选项值,那么我想执行的工作外部脚本喜欢加载过于球员:执行时的最后一个选项的值来选择外部脚本

<script scr="video.js" async="true" callback="myFunction()"></script> 

试图使用$.getScript,但它不工作,因为我想。 这是代码的一部分,我想补充:

$("select").change(function(){ 
    $(this).find("option:selected").each(function(){ 
     var optionValue = $(this).attr("value"); 
     if(optionValue){ 
      $(".box").not("." + optionValue).hide(); 
      $("." + optionValue).show(); 

     } else{ 
      $(".box").hide(); 
     } 
    }); 
}).change(); 

感谢您的帮助和理解, 巴特

+0

其中是选择选项? – tonoslfx

回答

0

主题可以被关闭,下面你可以检查我是如何做它的工作

$("select").change(function(){ 
    $(this).find("option:selected").each(function(){ 
     var optionValue = $(this).attr("value"); 
     if(optionValue){ 
      $(".box").not("." + optionValue).hide(); 
      $("." + optionValue).show(function(){ 
       var includes = $('[data-include]'); 
       jQuery.each(includes, function(){ 
        var file = 'views/' + $(this).data('include') + '.html'; 
        $(this).load(file); 
       }); 
       }); 
     } else{ 
      $(".box").hide(); 
     } 
    }); 
}).change();