【发布时间】:2012-03-13 15:31:24
【问题描述】:
我正在使用 PHP、HTML 和 jQuery。可以说这是我原来的工作“index.html”
<script type="text/javascript" src="jquery.js"></script>
<script>
var p1 = "This is part 1";
var p2 = "This is part 2";
$(document).ready(function(){
alert(p1);
$('#content').html(p2);
});
</script>
<div id="content"></div>
<div id="content2">Hello</div>
我想将代码分解为“index.html”和“otherFile.notSureWhatExt”,但它们就像在同一个文件中一样工作。
index.html:
<script type="text/javascript" src="jquery.js"></script>
<script type="notSureWhatType" src="otherFile.notSureWhatExt"></script>
<script>
var p1 = "This is part 1";
$(document).ready(function(){
alert(p1);
});
</script>
<div id="content"></div>
otherFile.notSureWhatExt:
<script>
var p2 = "This is part 2";
$(document).ready(function(){
$('#content').html(p2);
});
</script>
<div id="content2">Hello</div>
使用jsp,我可以简单地使用。但我现在不在这里。我想要的是在调用 index.html 时,我可以看到消息框“这是第 1 部分”和底部的 2 个 div,即“这是第 2 部分”和“你好”。
【问题讨论】:
标签: javascript html file