发生这种情况是由于JSFiddle将代码“插入”输出页面中的代码。
你拨弄采用4种方式输入代码:
- 的HTML框(左上),
- CSS盒(右上),
- JavaScript的框(左下)和
- “外部资源”(左侧菜单)。
输出部分(右下)将打印你把什么以上,而像这样:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo by Birdlaw</title>
<!-- Here goes the selected JS lib (jQuery 2.0.2 in your example) -->
<!-- Selected Extensions are here (in your case, bootstrap, then bootbox) -->
<style type="text/css">
<!-- Content of the CSS (top right) box goes here -->
</style>
<script type="text/javascript">//<![CDATA[
$(window).load(function(){
//<!-- Content of the JavaScript (bottom left) box goes here -->
//<!-- Actually, this can be configured (the second combo at left menu - "onLoad") -->
});//]]>
</script>
</head>
<body>
<!-- Content of the HTML box goes here -->
</body>
</html>
正如你所看到的,采取的jQuery出所选择的框架,并把它放在HTML盒子有不同的结果。
选择它作为框架将它放在之前扩展名(引导程序和bootbox)文件。当它位于HTML框中时,它被放在后面的扩展文件中,从而产生错误(因为这些文件需要jQuery)。
如何使它工作?如果您想将jQuery放在HTML框中“手动”,然后将所有扩展文件放在那里,并按正确顺序排列。这将使其按预期工作。
这是上面的updated fiddle, containing the fix。