課程
/前端開(kāi)發(fā)
/jQuery
/jQuery基礎(chǔ)(三)—事件篇
沒(méi)看到哪里定義了fn函數(shù)啊,而且不知道為啥要寫fn,但是我把fn注釋掉,然后就聚焦的時(shí)候,看不到慕課網(wǎng)三個(gè)字了,求解釋,fn
2016-10-25
源自:jQuery基礎(chǔ)(三)—事件篇 2-8
正在回答
fn只是函數(shù)名,是由你自己命名的,你可以改成an、bn、cn(取一個(gè)有意義的名字就行了)。
? //不同函數(shù)傳遞數(shù)據(jù)
? ? ? ? function fn(e) { ? ? ? ? ? ? ? ? ? ? ? //這里就定義函數(shù)fn了
? ? ? ? ? ? ?$(this).val(e.data) ? ? ? ? ? ?//this就調(diào)用執(zhí)行函數(shù)fn了
? ? ? ? }
? ? ? ? function a() { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //這里就定義函數(shù)a
? ? ? ? ? ? $("input:last").focusin('慕課網(wǎng)', fn) ? ? //focusin傳參
? ? ? ? a(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ???//調(diào)用執(zhí)行函數(shù)a
<!DOCTYPE html><html><head>??? <meta http-equiv="Content-type" content="text/html; charset=utf-8" />??? <title></title>??? <style>??? .left div,??? .right div {??????? width: 500px;??????? height: 50px;??????? padding: 5px;??????? margin: 5px;??????? float: left;??????? border: 1px solid #ccc;??? }??? .left div {??????? background: #bbffaa;??? }?? ???? .right div {??????? background: yellow;??? }??? </style>??? <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script></head><body>??? <h2>.focusin()方法</h2>??? <div class="left">??????? <div class="aaron">??????????? 點(diǎn)擊聚焦:<input type="text" />??????? </div>??? </div>??? <div class="right">??????? <div class="aaron1">??????????? 點(diǎn)擊聚焦并傳遞參數(shù):<input type="text" />??????? </div>??? </div>??? <script type="text/javascript">??????? //input聚焦??????? //給input元素增加一個(gè)邊框??????? $("input:first").focusin(function() {???????????? $(this).css('border','2px solid red')??????? })??? </script>??? <script type="text/javascript">??????? //不同函數(shù)傳遞數(shù)據(jù)??????? function fn(e) {??????????? $(this).val(e.data)??????? }??????? function a() {??????????? $("input:last").focusin("慕課網(wǎng)", fn)??????? }??????? a();??? </script></body></html>
舉報(bào)
jQuery第三階段開(kāi)啟事件修煉,掌握對(duì)頁(yè)面進(jìn)行交互的操作
2 回答handler是什么意思啊?
2 回答請(qǐng)教一下fn是什么意思
3 回答on函數(shù)中的第一個(gè)參數(shù)“Aaron”是什么意思?
1 回答為什么非要執(zhí)行a()函數(shù) a函數(shù)的意義是什么?
5 回答e.date是什么意思???e不是函數(shù)date里面的形參嗎
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-04-08
fn只是函數(shù)名,是由你自己命名的,你可以改成an、bn、cn(取一個(gè)有意義的名字就行了)。
2016-10-26
? //不同函數(shù)傳遞數(shù)據(jù)
? ? ? ? function fn(e) { ? ? ? ? ? ? ? ? ? ? ? //這里就定義函數(shù)fn了
? ? ? ? ? ? ?$(this).val(e.data) ? ? ? ? ? ?//this就調(diào)用執(zhí)行函數(shù)fn了
? ? ? ? }
? ? ? ? function a() { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //這里就定義函數(shù)a
? ? ? ? ? ? $("input:last").focusin('慕課網(wǎng)', fn) ? ? //focusin傳參
? ? ? ? }
? ? ? ? a(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ???//調(diào)用執(zhí)行函數(shù)a
2016-10-25
<!DOCTYPE html>
<html>
<head>
??? <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
??? <title></title>
??? <style>
??? .left div,
??? .right div {
??????? width: 500px;
??????? height: 50px;
??????? padding: 5px;
??????? margin: 5px;
??????? float: left;
??????? border: 1px solid #ccc;
??? }
??? .left div {
??????? background: #bbffaa;
??? }
?? ?
??? .right div {
??????? background: yellow;
??? }
??? </style>
??? <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
</head>
<body>
??? <h2>.focusin()方法</h2>
??? <div class="left">
??????? <div class="aaron">
??????????? 點(diǎn)擊聚焦:<input type="text" />
??????? </div>
??? </div>
??? <div class="right">
??????? <div class="aaron1">
??????????? 點(diǎn)擊聚焦并傳遞參數(shù):<input type="text" />
??????? </div>
??? </div>
??? <script type="text/javascript">
??????? //input聚焦
??????? //給input元素增加一個(gè)邊框
??????? $("input:first").focusin(function() {
???????????? $(this).css('border','2px solid red')
??????? })
??? </script>
??? <script type="text/javascript">
??????? //不同函數(shù)傳遞數(shù)據(jù)
??????? function fn(e) {
??????????? $(this).val(e.data)
??????? }
??????? function a() {
??????????? $("input:last").focusin("慕課網(wǎng)", fn)
??????? }
??????? a();
??? </script>
</body>
</html>