最近在项目中用了JS模板技术,用JS和AJAX驱动来实现前端和后台的分离,实现UI的多样化定制功能。
function myFunction(test1,test2)
{
var jh_input = document.getElementById(test1);
alert(jh_input.value);
var t2 = document.getElementById(test2);
alert(t2.value);
}
function extendFunction(callbackFunction,extend)
{
var extendStr = "this is extend string!";
var args = [];
if(typeof(extend) == "object")
{
for (var property in extend)
{
callbackFunction[property] = extend[property];
args.push(extend[property]);
}
}
callbackFunction["extendStr"] = extendStr;
args.push(extendStr);
callbackFunction.apply(this,args);
}
</script>
<form id=frm>
<div id=els>
<input type=text id=txt_name />
<input type=text id=txt_pwd />
</div>
<input type=button value=submit onclick="javascript:extendFunction(myFunction,{name:'txt_name',pwd:'txt_pwd'}); "; />
</body>