這節(jié)看不懂啊 。。。為什么 $(".aaron").focus(function() { $(this).css('border', '2px solid red') })這個(gè)沒有效果呢
這節(jié)看不懂啊 。。。為什么 $(".aaron").focus(function() { ? ? ? ? $(this).css('border', '2px solid red') ? ? })這個(gè)沒有效果呢
這節(jié)看不懂啊 。。。為什么 $(".aaron").focus(function() { ? ? ? ? $(this).css('border', '2px solid red') ? ? })這個(gè)沒有效果呢
舉報(bào)
2016-12-01
這一段本身就是不實(shí)現(xiàn)效果的。
注意原文中這一句話:“div是input的父元素,當(dāng)它包含的元素input觸發(fā)了focus事件時(shí),它就產(chǎn)生了focusin()事件?!?/p>
所以說,如果代碼如下,則input上出現(xiàn)效果,且div上產(chǎn)生focusin( )事件
2018-06-02
但是focus事件不是綁定到.arron的div上了嗎,點(diǎn)擊div區(qū)域不應(yīng)該觸發(fā)嗎
2017-01-11
<!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>
? ? <h4>.focusin與blur</h4>
? ? <div class="left">
? ? ? ? <div class="aaron">
? ? ? ? ? ? 點(diǎn)擊觸發(fā)焦點(diǎn)(無反應(yīng)):
? ? ? ? ? ? <input type="text" />
? ? ? ? </div>
? ? ? ? <div class="aaron1">
? ? ? ? ? ? 點(diǎn)擊觸發(fā)焦點(diǎn)并冒泡:
? ? ? ? ? ? <input type="text" />
? ? ? ? </div>
? ? </div>
? ? <script type="text/javascript">
? ? $(".aaron").focusin(function() {
? ? ? ? $(this).css('border','1px solid red');
? ? })
? ? $(".aaron1").focusin(function() {
? ? ? ? $(this).find('input').val('冒泡捕獲了focusin事件')
? ? })
? ? </script>
? ? </script>
? ? <h4>.focusout與blur</h4>
? ? <div class="right">
? ? ? ? <div class="aaron3">
? ? ? ? ? ? 點(diǎn)擊觸發(fā)失去焦點(diǎn)(無反應(yīng)):
? ? ? ? ? ? <input type="text" />
? ? ? ? </div>
? ? ? ? <div class="aaron4">
? ? ? ? ? ? 點(diǎn)擊觸發(fā)失去焦點(diǎn)并冒泡:
? ? ? ? ? ? <input type="text" />
? ? ? ? </div>
? ? </div>
? ? <script type="text/javascript">
? ? $(".aaron3").focusout(function() {
? ? ? ? $(this).css('border', '2px solid red')
? ? })
? ? $(".aaron4").focusout(function() {
? ? ? ? $(this).find('input').val('冒泡捕獲了focusout事件')
? ? })
? ? </script>
</body>
</html>
這樣處理就可以看到紅框了
2016-12-12
關(guān)鍵在于? “處理”兩個(gè)字
focus與blur、focusin與focusout都能接受到冒泡
但是 focus與blur對冒泡不會(huì)處理,focusin與focusout會(huì)對冒泡事件處理
區(qū)別就在于“處不處理”冒泡事件
2016-11-04
你可以吧aaron改成input自己看看效果??!
2016-10-30
就算在 .left里產(chǎn)生了 focuin() 跟他自己有什么關(guān)系呢 這個(gè) css樣式為什么沒有實(shí)現(xiàn)