伪代码如下;
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<a id="eng" href="">ENGLISH</a>
</body>
</html>
<script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.js"></script>
<script>
$(function(){
$("#eng").on('click', function(){
fn1();
fn2();
fn3();
});
function fn1(){
console.log('fn1');
};
function fn2(){
console.log('fn2');
}
function fn3(){
console.log('f3');
}
});
function fnK1(){
console.log('fnK1');
}
function fnK2(){
console.log('fnK2');
}
function fnK3(){
console.log('fnK3');
}
fnK1();
fnK2();
fnK3();
</script>
这里的逻辑是,正常情况下加载fnK1(), fnK2(), fnK3()这三个方法;点击id=eng这个链接之后,加载click事件里的三个方法;
更新了一下主楼的伪代码,可以在本地跑一下看看;
把代码抽出来写了个demo定位一下问题,fn1()这三个方法都执行了;我知道是因为fnK1()这三个方法是最后顺序执行的,所以导致的这个问题;所以,应该是这块的代码逻辑有问题...
有只小跳蛙
当年话下
红糖糍粑
浮云间