比如a.js文件有如下
<script>
function rec1(){
var tab_t = document.getElementById("tab_t");
var tab_t_li = tab_t.getElementsByTagName("li");
var tab_c = document.getElementById("tab_c");
var tab_c_li = tab_c.getElementsByTagName("div");
var len = tab_t_li.length;
var i = 0;
for (i = 0; i < len; i++)
{
tab_t_li[i].index = i;
tab_t_li[i].onclick = function()
{
for (i = 0; i < len; i++)
{
tab_t_li[i].className = '';
tab_c_li[i].className = 'hide'
}
tab_t_li[this.index].className = 'act';
tab_c_li[this.index].className = '';
}
}
}
</script>
然后我index.html文件中有个选项卡,那么如何调用这个选项卡的js方法?首先用script标签引用a.js,那么如何使用这个rec1的选项卡方法呢? 小白求解
参考链接:https://segmentfault.com/a/11...