the event of focus and mousedown is difference on behavior betwen ie6/7/8 and modern broswer

    输入框获得焦点后,点击我,在所有浏览器下,输入框都失去焦点
        /***********************************
         ** Multiline block comments
         **********************************/
        $("#txt_1").focus(function() {
          $("#log_1").append("
  1. text input获的焦点了
  2. "); }) .blur(function() { $("#log_1").append("
  3. text input失去焦点了
  4. "); }); $("#wrap_1").mousedown(function(event) { });
    输入框获得焦点后,点击我,在ie6/7/8下,输入框会失去焦点,其他标准浏览器输入框不会失去焦点
          /***********************************
             ** Multiline block comments
             **********************************/
          $("#txt_2").focus(function() {
            $("#log_2").append("
    1. text input获的焦点了
    2. "); }) .blur(function() { $("#log_2").append("
    3. text input失去焦点了
    4. "); }); $("#wrap_2").mousedown(function(event) { event.preventDefault();//return false; });
      得出的结论是:
      也就是说:mousedown事件在有输入框获得焦点的情况下,它的默认动作会触发输入框的失去焦点事件。 如果你清除默认动作,那么输入框就不会失去焦点。但是ie6/78/即使清除默认动作,输入框也会失去焦点
      ECMA5-Object-and-Properties »
      comments powered by Disqus
      Fork me on GitHub