誰能用通俗易懂的語言講講這段代碼的意思?
function fn(e) {
? ? ? ? ? ? ?$(this).val(e.data)
? ? ? ? }
? ? ? ? function a() {
? ? ? ? ? ? $("input:last").focusin('慕課網(wǎng)', fn)
? ? ? ? }
? ? ? ? a();
function fn(e) {
? ? ? ? ? ? ?$(this).val(e.data)
? ? ? ? }
? ? ? ? function a() {
? ? ? ? ? ? $("input:last").focusin('慕課網(wǎng)', fn)
? ? ? ? }
? ? ? ? a();
2016-08-27
舉報(bào)
2016-08-28
a();-->調(diào)用?function a()函數(shù) ,?$("input)選出所有input標(biāo)簽的集合,$("input:last")就是從input標(biāo)簽集合中取出最后一個(gè)便簽,focusin()獲得焦點(diǎn)事件,$("input:last").focusin('慕課網(wǎng)', fn)意為 給input標(biāo)簽集合中最后的一個(gè)input便簽設(shè)置獲得焦點(diǎn)事件,參數(shù)為 ‘慕課網(wǎng)‘ fn是回調(diào)函數(shù) 即是function fn(e)函數(shù),this是觸發(fā)事件目標(biāo)(在這里也就是是前面取得的最后input標(biāo)簽),?$(this)把DOM的this對(duì)象轉(zhuǎn)化為JQuery的對(duì)象,?$(this).val(?e.data) 是對(duì)觸發(fā)事件對(duì)象設(shè)置值,值e.data 就是前面參數(shù)?'慕課網(wǎng)' 。
其實(shí)
function a() {
? ? ? ? ? ? $("input:last").focusin('慕課網(wǎng)', fn)
? ? ? ? }
等價(jià)
function a() {
? ? ? ? ? ? $("input:last").focusin('慕課網(wǎng)',function fn(e) {? ??
????????????????????????????????????$(this).val(e.data)? ? ? })
? ? ? ? }