项目中经常调用js ,jsp 页面中写太多js ,过于繁琐,于是看了资料对js进行简单的封装,调用;
在a.jsp中调用b.js;
b.js进行简单封装
(function(){
var myTest=function(wx){
alert(wx.id);
}
window.myTest=myTest;
})();
<script src="test.js"></script>
<script>
new myTest({id:"a"});
</script>
运行结果后,alert(a);