JS的静态类的定义格式为
a.js
var test ={
geta:function()
{
return 'a';
},
getb:function ()
{
return 'b';
}
}
在html里面的调用方式是
<script language="javascript" src="a.js"></script>
<script language="javascript">
window.onload = function()
{
window.alert(test.geta());
}
</script>
<script language="javascript">
window.onload = function()
{
window.alert(test.geta());
}
</script>
JS的普通类的定义格式为
b.js
function test()
{
function geta()
{
return 'a';
}
function getb()
{
return 'b';
}
}
在html里面的调用方式是
<script language="javascript" src="b.js"></script>
<script language="javascript">
window.onload = function(){
var test1 = new test();
window.alert(test1.geta());
}
</script>