zoukankan      html  css  js  c++  java
  • 太难了。

    http://www.webfront-js.com/
    大神网站

    Document
    <script type="text/javascript">
        let app = document.getElementById('app')
    
        let appinput = document.getElementById('appinput')
    
    
        document.flg = true
        let appcount = 0
        let windowcount = 0
    
        let posStart = 0
        let posEnd = 0
    
        app.addEventListener('mousedown', function(e) {
            console.log('app.onmousedown come in == ' + appcount++ + ' selectionStart == ' + this.selectionStart)
                //通过是否支持createTextRange判断是否是IE
            if (this.createTextRange) {
                var rg = this.createTextRange();
                rg.collapse(false);
                rg.select();
            } else {
                var th = this;
                //这里注意一定要定义this为一个变量
                //setTimeout才能从变量作用域中得到这个对象
                //否则其延迟是由window调用的,this指向的是globle对象。
                setTimeout(function() {
                    var len = th.value.length;
                    th.setSelectionRange(len, len);
                }, 20);
            }
    
        }, true)
    
        function do1(e) {
            let curpos = e.selectionStart
            let nextpos = e.value.indexOf('
    ', curpos)
            let prepos = e.value.substr(0, curpos).lastIndexOf('
    ') + 1
            console.log(prepos + ' ' + curpos + ' ' + nextpos)
            if (prepos == curpos) {
                e.setSelectionRange(nextpos, nextpos);
            }
        }
    </script>
    
  • 相关阅读:
    css3实现文本渐变
    元组--购物车实战
    js事件冒泡
    openssl生成v3版自签证书
    linux中可以在哪些地方增加环境变量
    linux下如何找到USB转串口
    linux下通过shell命令测试串口
    CANopen协议
    ubuntu使用虚拟can(vcan)
    移植python3到flash有限的arm
  • 原文地址:https://www.cnblogs.com/kutsu/p/14642856.html
Copyright © 2011-2022 走看看