为什么点击切换的时候会说switchlider没有定义呢?
这是a标签
<div class="ctrl" id="template_ctrl">
<a class="ctrl-i" id="ctrl_{{index}}" href="javascript:switchlider({{index}});"><img src="{{index}}.jpg"></a>
</div>
function add(){
var tpl_main = g('template_main').innerHTML.replace(/^\s*/,'').replace(/\s*$/,'');
var tpl_ctrl = g('template_ctrl').innerHTML.replace(/^\s*/,'').replace(/\s*$/,'');
//定义最终输出HTML的变量
var out_main = [];
var out_ctrl = [];
for(i in data){
var _html_main = tpl_main.replace(/{{index}}/g,data[i].img).replace(/{{h2}}/g,data[i].h1).replace(/{{h3}}/g,data[i].h2);
var _html_ctrl = tpl_ctrl.replace(/{{index}}/g,data[i].img);
out_main.push(_html_main);
out_ctrl.push(_html_ctrl);
}
//把HTML会写到对应的DOM里面
g('template_main').innerHTML = out_main.join('');
g('template_ctrl').innerHTML = out_ctrl.join('');
//切换幻灯片
function switchlider(n){
alert("qwewq");
}
}
window.onload = function(){
add();
}