這節看不懂啊 。。。為什么 $(".aaron").focus(function() { $(this).css('border', '2px solid red') })這個沒有效果呢
這節看不懂啊 。。。為什么 $(".aaron").focus(function() { ? ? ? ? $(this).css('border', '2px solid red') ? ? })這個沒有效果呢
這節看不懂啊 。。。為什么 $(".aaron").focus(function() { ? ? ? ? $(this).css('border', '2px solid red') ? ? })這個沒有效果呢
2016-10-30
舉報
2016-12-01
這一段本身就是不實現效果的。
注意原文中這一句話:“div是input的父元素,當它包含的元素input觸發了focus事件時,它就產生了focusin()事件。”
所以說,如果代碼如下,則input上出現效果,且div上產生focusin( )事件
2018-06-02
但是focus事件不是綁定到.arron的div上了嗎,點擊div區域不應該觸發嗎
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">
? ? ? ? ? ? 點擊觸發焦點(無反應):
? ? ? ? ? ? <input type="text" />
? ? ? ? </div>
? ? ? ? <div class="aaron1">
? ? ? ? ? ? 點擊觸發焦點并冒泡:
? ? ? ? ? ? <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">
? ? ? ? ? ? 點擊觸發失去焦點(無反應):
? ? ? ? ? ? <input type="text" />
? ? ? ? </div>
? ? ? ? <div class="aaron4">
? ? ? ? ? ? 點擊觸發失去焦點并冒泡:
? ? ? ? ? ? <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
關鍵在于? “處理”兩個字
focus與blur、focusin與focusout都能接受到冒泡
但是 focus與blur對冒泡不會處理,focusin與focusout會對冒泡事件處理
區別就在于“處不處理”冒泡事件
2016-11-04
你可以吧aaron改成input自己看看效果??!
2016-10-30
就算在 .left里產生了 focuin() 跟他自己有什么關系呢 這個 css樣式為什么沒有實現