zoukankan      html  css  js  c++  java
  • JS,JQ及时监听input值的变化,MUI的input搜索框里的清除按钮的点击监听事件

    JS:

    document.getElementById("input对象的ID").addEventListener('input',function(){
        console.log("aaaaa");
    });

    JQ:

    $("input对象").on("input  propertychange",function(){
       console.log($(this).val());
    });

       这个也适用与textarea标签的内容的及时监听,只需要把对象名改变就行了,其它不用变。

    MUI 清除按钮的点击的监听:

    mui('input对象')[0].addEventListener('focus', function(){
         mui(".mui-icon-clear")[0].addEventListener('tap',function(){
           console.log("aaaaa");
         });
    })

      说明:因为MUI搜索框里自带的清除按钮是当input框focus,即input获取焦点的时候才出现的,如果不要input的focus监听事件,那么清除按钮的点击事件是不会监听到的。

         我觉得是因为清除按钮,下面的那个span是文档加载完之后,MUI的js加载进去的,所以当不先监听input的focus事件的时候,清除按钮的监听事件是找不到那个DOM对象的,所以就会报这样的错误。

     

  • 相关阅读:
    Codeforces Round #425 (Div. 2) Problem A Sasha and Sticks (Codeforces 832A)
    bzoj 2301 Problem b
    bzoj 1101 [POI2007]Zap
    bzoj 2005 能量采集
    bzoj 2527 Meteors
    bzoj 2724 [Violet 6]蒲公英
    回顾树状数组
    bzoj 3237 连通图
    bzoj 2733 永无乡
    Codeforces 817C Really Big Numbers
  • 原文地址:https://www.cnblogs.com/zjjDaily/p/6076983.html
Copyright © 2011-2022 走看看