一方静土

导航

 

通过 AJAX 请求来获得并运行一个 JavaScript 文件:

 

HTML 代码:

<button id="go">Run</button>
<div class="block"></div>

jQuery 代码:

jQuery.getScript("http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js",
 function(){
  $("#go").click(function(){
    $(".block").animate( { backgroundColor: 'pink' }, 1000)
      .animate( { backgroundColor: 'blue' }, 1000);
  });
});
posted on 2016-06-02 10:11  Daniel Rudy  阅读(233)  评论(0编辑  收藏  举报