由于无法控制的原因,我必须通过动态附加的<script>
标记加载jQuery,并且仅在某些任意事件上执行此操作, 而不是在页面加载时执行。
我的问题是在检测jquery准备就绪的时刻,因为以下代码不起作用:
(function(){
var s=document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js');
document.getElementsByTagName('head')[0].appendChild(s);
})()
$(document).ready(function() {
// something that uses jquery and currently doesn't work
});
如何检测准备在此特定配置中使用jquery的时刻?
提前致谢